#include <stdio.h>
int main(){
int *p = '\0';
if (p == NULL){
// this block will get executed.
}
return 0;
}
I have read that 0
, NULL
and \0
are all equal to the integer constant 0
in C.
So is the above code technically correct in setting and checking for a NULL pointer? I guess it still needs to be avoided as \0
is mainly used to terminate strings and its usage here is confusing?