From time to time, I run into communications issue with other programmers, when we talk about NULL. Now NULL could be
a NULL pointer
the NUL character
an empty data element in some sort of database.
NUL seems to be the most confusing. It is the ASCII character 0x00.
I tend to use ‘\0’ in my code to represent it. Some developers in my group
tend to prefer to simply use 0, and let the compiler implicitly cast it to a char.
What do you prefer to use for NUL? and why?
I use
'\0'for the nul-character andNULLfor pointers because it is clearest in both cases.BTW, both
0and'\0'areints in C and either one will be converted tocharwhen stored in acharvariable.