When I compile this code:
void rep_and_print(char * str, char * patt, int l, int i)
{
char * pch; // pointer to occurence
char * s;
s = str; // save original pointer
if (i == 0)
{
while ( (pch = strstr(str,patt)) != NULL)
{
// FOUND
memset (pch,'*',l); // Set asterisk
str = pch + l; // move pointer to the end of asterisks to found new occurences
}
}
else
{
while ( (pch = strcasestr(str,patt)) != NULL)
{
// FOUND
memset (pch,'*',l); // Set asterisk
str = pch + l; // move pointer to the end of asterisks to found new occurences
}
}
printf ("%s",s);
}
I got this error:
warning: assignment makes pointer from integer without a cast [enabled by default]
while ( (pch = strcasestr(str,patt)) != NULL)
and there is an arrow point to the equal sign that is between pch and strcasestr
-Wall?strcasestrisn't a standard function and may not be defined in<string.h>, so that your compiler assumes that it returns anint. That would explain why ther isn't an error for the same code withstrstr.