include <stdio.h>
int main()
{
char *p = NULL;
char *q = 0;
if (p)
printf(" p ");
else
printf("nullp");
if (q)
printf("q
");
else
printf(" nullq
");
}
Assigning the value NULL to a pointer variable makes it a NULL pointer. Another way in which we can define a pointer variable as NULL pointer is by assigning it a value 0.
In your code, both the pointer variables p and q are defined as NULL pointers and so the body of else will be executed in both the cases. Also make the first line of your code as #include <stdio.h>.