简体   繁体   中英

Warning: comparison between pointer and integer, assignment make integer from pointer without a cast?

I'm getting these warnings right now and I'm not sure why. I've put the warning message in the code next to the line it corresponds with.

void removeNewLine (char * userName, int charLenght)
{
int i=0; 

do {
    if (userName [i]=='/n') //comparison between pointer and integer
    {
        userName [i]='/0'; //assignment makes integer from pointer w/o cast
    }
i++;
} while (i<charLenght);

}

You have the wrong slash. You want '\\n' for newline and '\\0' for NULL character.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM