self referential structures in c simple example program

Self-referential structures are those structures that contain a reference to data of its same type, i.e, in addition to other data, a self-referential structure contains a pointer to a data that is of the same type as that of the structure. For example, Consider the structure node given as follows.

Struct node;
Int val;
Struct node*next;

Here the structure node will contain two types of data-an integer val and next, which is a pointer to a node. Actually, self-referential structure is the foundation of other data structures.

The basic unit (or node) as specified in C is called a self-referential structure, one in which a member(s) is a pointer to a structure(s) of the same type.


Post a Comment