Are NUL and NULL interchangeable in C?

c, c++

Solution

`NUL` is the notation for an ASCII character code 0.

`NULL` is a macro defined in `stddef` for the null pointer.

So, no, they are not to be used interchangeably.

Problem

Just read pointer on C book by Kenneth Reek. It says that a NUL byte is one whose bits are all 0, written like this `'\0'` and NULL has a value 0 which refers to a pointer whose value is zero. Both are integers and have the same value, so they could be used interchangeably. and this code also: ``` char const *keyword[] = { "do", "for", "if", "register", "return", "switch", "while", NULL }; ``` In this code, the NULL lets functions that search the table detect the end of the table. So, can we interchange NULL and NUL macros?

Original source

Related problems