I've been constantly getting this error for the following block of program, isn't an iterator also a pointer when using such string data types?
error: cannot convert 'std::basic_string<char>::iterator
{aka __gnu_cxx::__normal_iterator<char*, std::basic_string<char> >}'
to 'const char*' for argument '2' to 'char* strcat(char*, const char*)'
strcat(temp, str1.begin());
^
int areRotations(string str1, string str2)
{
int size1 = str1.length();
int size2 = str2.length();
char* temp= new char[size1+size2+1];
void *ptr;
if (size1 != size2)
return 0;
strcat(temp, str1.begin());
strcat(temp, str1.begin());
/* Now check if str2 is a substring of temp */
ptr = strstr(temp, str2);
if (ptr != NULL)
return 1;
else
return 0;
}