4 ms·
NULL isn't always the integer 0 in C. It's implementation-defined.
by chongli 2y ago
NULL isn't always the integer 0 in C. It's implementation-defined.
- loeg 2y agoIn every real world implementation anyone cares about, it's zero. Also I believe it is defined to compare equal to zero in the standard, but don't quote me on that.
- tzs 2y ago> Also I believe it is defined to compare equal to zero in the standard, but don't quote me on that. That's true for the literal constant 0. For 0 in a variable it is not necessarily true. Basically when a literal 0 is assigned to a pointer or compared to a pointer the compiler takes that 0 to mean whatever bit pattern represents the null pointer on the target system.