Hi I am trying to use the Null function in a for statement which is below but I keep getting the error 'warning: comparison between pointer and integer'
for(i = 0; i == NULL; i++)
it would be great if some one could tell me how to fix it thanks
Printable View
Hi I am trying to use the Null function in a for statement which is below but I keep getting the error 'warning: comparison between pointer and integer'
for(i = 0; i == NULL; i++)
it would be great if some one could tell me how to fix it thanks
In C, NULL is being defined as a void pointer to 0. As a result, the data types both for i and NULL don't match and the compiler generates a warning.
BTW, why do you have to compare i=0 with NULL. The code within the for-loop only executes once which is exactly the same as executing the same code without the for-loop.Code:#define NULL ((void *)0)
And why compare it with NULL, anyway? What's wrong with "0"?