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
str[i]
is a character. NULL
is a pointer. You can't meaningfully compare those two data types (although they may or may not be implemented as the same size of integer internally). That's all the error message means.
Not that the comparison is not only type-incorrect, it also doesn't do what you probably mean. You seem to assume that a character array with an incomplete initializer would be automatically terminated with a \0 character, but that rule applies to string literals, not to character arrays you create yourself. As it is, you're invoking undefined behaviour.