Self Referential Structure in C Language

Self Referential Structure in C Language

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;  
  }  
}

Spread the love
Lesson tags: self referential structure, self referential structure in c, Self Referential Structure in C Language
Back to: C Programming Language
Spread the love