Wrong using of a POINTER constant defined as NULL macros in C:
while( str1[i] != NULL) /* wrong */
/* Right code: */
while (str1[i]) /* (I prefer this form); or */
while (str[i] != '\0') /* or */
while (str[i] != 0)
The C compiler can define NULL as
(void*)0 or simple 0. In the 1st case you are trying to compare char promoted to int with a pointer to void.
Moral: NULL is not a zero alias in C, use NULL only for pointer values.
Last edited by ArkM; Dec 2nd, 2008 at 6:04 am.
Reputation Points: 1234
Solved Threads: 347
Postaholic
Offline 2,001 posts
since Jul 2008