In C, there appear to be differences between various values of zero -- NULL
, NUL
and 0
.
I know that the ASCII character
It appears that a number of people misunderstand what the differences between NULL, '\0' and 0 are. So, to explain, and in attempt to avoid repeating things said earlier:
A constant expression of type int
with the value 0, or an expression of this type, cast to type void *
is a null pointer constant, which if converted to a pointer becomes a null pointer. It is guaranteed by the standard to compare unequal to any pointer to any object or function.
NULL
is a macro, defined in as a null pointer constant.
\0
is a construction used to represent the null character, used to terminate a string.
A null character is a byte which has all its bits set to 0.