Skip to content
Snippets Groups Projects
null_pointer_1.c 325 B
Newer Older
Andre Maroneze's avatar
Andre Maroneze committed
int y=0;
int main() {
  assert(sizeof(long)==sizeof(int*));
  long x=0;
  int *p = (int *)x;
  // is the value of p a null pointer?
  _Bool b1 = (p == NULL);// guaranteed to be true?
  _Bool b2 = (p == &y);  // guaranteed to be false?
  printf("(p==NULL)=%s  (p==&y)=%s\n", b1?"true":"false", 
         b2?"true":"false");
}