246 Chapter 11 Pointers
Assuming a variable n3were also defined to be of type struct entry,you could add
another link with the following statement:
n2.next = &n3;
This resulting chain of linked entries, known more formally as a linked list, is illustrated
in Figure 11.5. Program 11.6 illustrates this linked list.
n1
value
next
n2
value
next
100
200
n3
value
next
300
Figure 11.5 A linked list.
Program 11.6 Using Linked Lists
// Function to use linked Lists
#include <stdio.h>
int main (void)
{
struct entry
{
int value;
struct entry *next;
};
struct entry n1, n2, n3;
int i;