jeudi 4 février 2016

assignment makes pointer from integer without a cast enabled by default

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

Aucun commentaire:

Enregistrer un commentaire