Self Referential Structure
Self referential structure contains a pointer variable of itself . it is mainly used for implementing data structures like stack, queue, linked list, trees and graphs in C.
Example
struct NODE
{
float data;
struct NODE *link;
};
int main()
{
struct NODE *START = NULL ;
struct NODE *N ;
N = malloc(sizeof(struct NODE) ) ;
printf( “Enter the data part of node \n ” ) ;
scanf(“%f”,&N->data) ;
N->link = NULL ;
if( START == NULL )
START = N ;
else
{
N->link = START;
START=N;
}
}
Popular Books of Computer Science