|
Consider the following example to illustrator the concept of linking. Suppose we define a structure as follows
struct linked_list
{
float age;
struct linked_list *next;
}
struct Linked_list node1,node2;
this statement creates space for nodes each containing 2 empty fields
node1
node1.age
node1.next
node2
node2.age
node2.next
The next pointer of node1 can be made to point to the node 2 by the same statement.
node1.next=&node2;
This statement stores the address of node 2 into the field node1.next and this establishes a link between node1 and node2 similarly we can combine the process to create a special pointer value called null that can be stored in the next field of the last node
|