In C, there appear to be differences between various values of zero -- NULL, NUL and 0.
I know that the ASCII character
If NULL and 0 are equivalent as null pointer constants, which should I use? in the C FAQ list addresses this issue as well:
C programmers must understand that
NULLand0are interchangeable in pointer contexts, and that an uncast0is perfectly acceptable. Any usage of NULL (as opposed to0) should be considered a gentle reminder that a pointer is involved; programmers should not depend on it (either for their own understanding or the compiler's) for distinguishing pointer0's from integer0's.It is only in pointer contexts that
NULLand0are equivalent.NULLshould not be used when another kind of0is required, even though it might work, because doing so sends the wrong stylistic message. (Furthermore, ANSI allows the definition ofNULLto be((void *)0), which will not work at all in non-pointer contexts.) In particular, do not useNULLwhen the ASCII null character (NUL) is desired. Provide your own definition
#define NUL '\0'
if you must.