Possible Duplicate:
Is NULL always zero in C?
Following code:
char *p1 = 0;
char *p2 = NULL;
char *p3 = (char *)0;
if (NULL == 0)
printf("the NULL is same as 0\n");
printf("0 : %s\n", 0);
printf("p1 : %s\n", p1);
printf("p1 : %x\n", p1);
printf("&p1 : %x\n", &p1);
printf("NULL : %s\n", NULL);
printf("p2 : %s\n", p2);
printf("p2 : %x\n", p2);
printf("&p2 : %x\n", &p2);
printf("*p2 : %s\n", *p2);
output:
the NULL is same as 0
0 : (null)
p1 : (null)
p1 : 0
&p1 : bf9a0204
NULL : (null)
p2 : (null)
p2 : 0
&p2 : bf9a0208
Segmentation fault (core dumped)
I wonder:
What the (null) stands for?
Does the pointer p1 or p2 point to address 0x0?
Does the statement printf("p1 : %x\n", p1); outputs p1 : 0 indicates p1 point to address 0x0?