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
37
38
39
40
41
42
43
44
/*
    variables of type "struct Node" have two fields:

    - pointer to next node
    - some value
*/

struct Node {
    struct Node    *next;
    long            value;
};

/*
   predecalre all nodes so that we in the initialization of a node we can point
   to a node that gets defined later:
*/
extern struct Node a;
extern struct Node b;
extern struct Node c;
extern struct Node d;

/*
    define all nodes as global variables:
*/

struct Node a = {
    &c,     // &c is the address of global variable b
    'A'
};

struct Node b = {
    &d,     // &d is the address of global variable b
    'B'
};

struct Node c = {
    &b,     // &b is the address of global variable b
    'C'
};

struct Node d = {
    &a,     // &a is the address of global variable b
    'D'
};