4 ms·
> I bet that around 99% of C code in the real world assumes that NULL == 0. That is the correct assumption as 0 is interpreted as a null pointer constant when
by josefx 4y ago
> I bet that around 99% of C code in the real world assumes that NULL == 0.
That is the correct assumption as 0 is interpreted as a null pointer constant when interpreted as a pointer. As far as I understand you have to do something like memset(ptr,0,sizeof(int*)) to bypass this conversion and get a pointer to the memory location 0 instead of a NULL pointer.
- saurik 4y agoYeah, but that memset is super common due to how people clear structs.