#include /* C example */ #include /* for malloc and free */ struct node { /* a node on a doubly linked list */ int value; struct node *prev; struct node *next; }; int main(int argc, char **argv) { struct node *const p = malloc(sizeof (struct node)); if (p == NULL) { fprintf(stderr, "%s: can't allocate %u bytes\n", /* not portable */ argv[0], sizeof (struct node)); return EXIT_FAILURE; } p->value = 10; p->prev = p->next = NULL; printf("value == %d, prev == %p, next == %p.\n", p->value, p->prev, p->next); printf("A struct node occupies %u bytes.\n", sizeof (struct node)); printf("The hidden numbers are %u and %u.\n", /* unofficial; not portable */ ((size_t *)p)[-2], ((size_t *)p)[-1]); free(p); return EXIT_SUCCESS; }