What is the output of the following C program on a 64-bit system?
#include <stdio.h>
#include <stdlib.h>
struct node {
int v;
struct node *next;
};
int main(void) {
struct node *n = calloc(1, sizeof *n);
if (n == NULL)
return 1;
printf("%d %s\n", n->v, n->next == NULL ? "NULL" : "set");
free(n);
return 0;
}
calloc() sets every byte to zero. On all mainstream platforms a pointer with all bits zero is a null pointer, so next is NULL and v is 0 – a convenient way to create an empty node.