This article is an Array of Linked Lists example.
To build a Linked List we need a self referencing structure, here we use the:
struct node {
char far data [6];
struct node far *next;
} s;
To build an Array of Linked Lists we declare an array of pointers that point to pointers pointing self referencing structures of node type, writing :
struct node far ** [6]
Next, we find free space at the Heap for each one of these pointers doing memory allocation using malloc() function and at the end we insert nodes at each one of the six Linked Lists using AppendNode() function as in article no 20. Realloc() function can't be used asking for a larger Heap space because realloc() copys the old space to the new larger Heap space and as a result we receive six Linked Lists that are copies.
At the example we insert strings at the nodes of the six Linked Lists and as a new experience we use the Large memory model having Far pointers (4 bytes long). See Keil page
CORRECTLY DECLARING VARIABLES WITH MEMORY SPACES
The C code The result |