Is NULL always zero in C?

c, null, pointers, zero

Solution

I'm assuming you mean the null pointer. It is guaranteed to compare equal to `0`.1 But it doesn't have to be represented with all-zero bits.2

See also the comp.lang.c FAQ on null pointers.

- See C99, 6.3.2.3.

- There's no explicit claim; but see the footnote for C99, 7.20.3 (thanks to @birryree in the comments).

Problem

I was interviewing a guy for a mid-level software engineering position yesterday, and he mentioned that in C, NULL is not always zero and that he had seen implementations of C where NULL is not zero. I find this highly suspect, but I want to be sure. Anyone know if he is right? (Responses will not affect my judgement on this candidate, I've already submitted my decision to my manager.)

Original source

Related problems