#include <stdio.h> #include <stdlib.h> typedef struct node { int value; // 4 bytes struct node *next; // 8 bytes } node_t; node_t *new_node(int v); int main(int argc, char *argv[]) { node_t *head = NULL; int x; scanf("%d", &x); node_t *tmp = new_node(x); if(head == NULL) { // case 1 head = tmp; } else { // case 2 tmp->next = head; head = tmp; } printf("%d\n", head->value); printf("%x\n", head->next); return 0; } node_t *new_node(int v) { node_t *n = NULL; n = (node_t *)malloc(sizeof(node_t)); if(n == NULL) { fprintf(stderr, "Error: malloc failed.\n"); return NULL; } // Set the value and next variables of n n->value = v; n->next = NULL; return n; }