Read this: Question 5.1
More here: Null Pointers
Why not make a complete example?
Code:
#include <stdio.h>
int main(void)
{
char *str = "CBOARD";
while (*str != NULL)
{
/*..do something..*/
str++;
}
return 0;
}
/*
main.c|7|warning: comparison between pointer and integer
*/
As you can see, your first example generates a warning because you're dereferencing the pointer for the comparison.
Your second example should actually work:
Code:
#include <stdio.h>
int main(void)
{
char *str = "CBOARD";
while (str == NULL)
{
printf("In the loop\n");
str++;
}
return 0;
}
There is no output because "str" is pointing somewhere - it is not NULL.