1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#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);
head = new_node(x);
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;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX