The strspn() function finds up to what length two strings are identical.
This function is defined in <cstring> header file.
#include<iostream>#include<cstring>using namespace std;
char str1 ="wikimass is awesome";
char str2 ="wikipedia is great";
long len =strspn(str1, str2);
cout <<"Length of initial segment matching: "<< len;