2 ms·
Additionally in a boolean context a null pointer is indistinguishable from "false" (meaning, zero). http://c-faq.com/null/ptrtest.html http://c-faq.com/null/pt
by loup-vaillant 12y ago
Additionally in a boolean context a null pointer is indistinguishable from "false" (meaning, zero).
http://c-faq.com/null/ptrtest.html http://c-faq.com/null/ptrtest.html
For practical purposes, the null pointer and the integer `0` are one and same.
- dllthomas 12y ago"For practical purposes, the null pointer and the integer `0` are one and same." For most practical purposes, which is why I said that it wasn't a terrible approximation. However, they can be distinguished on some architectures: intptr_t x = 0; void *p = 0; x == *(intptr_t*)(char*)&p; I can easily construct fantasy scenarios (involving more than a bit of Doing It Wrong) where this would be relevant. I'm not convinced it couldn't ever be relevant without Doing It Wrong, if one in fact needed to work on that kind of a system.