Jeungwoo Park Jeungwoo Park - 2 months ago 6
C Question

can i see what value of pointing NULL pointer?

#include<stdio.h>
int main() {
int *p=NULL;
if (p == NULL) {
printf("%x",*p );
}
return 0;
}


If I can, How?
If I can't, What value in it?

Answer

No, you cannot in general dereference a NULL pointer, that gives undefined behavior.

That's sort of the point, so this idea is a bit strange.

Note that this doesn't mean that your code won't run on any platform or produce a result, but it still violates the language specification so the result from running it on some particular implementation doesn't matter.