I have a bit stupid question about program in C. My compiler says me: warning: comparison between pointer and integer. I really don\'t know why. I only want to writ
NULL
is defined as a pointer type, usually (void*)0
. This means it should not be compared to characters (which are promoted to integers when used on their own). The problem is with the following: str[i] != NULL
. The correct way to do this is compare it to something of the same type, in this case you are looking for the null character, '\0'
.