C pointer to structure within same Structure

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

Pointer to Structure Within the same Structure : Self Referential

  1. In this Type , Structure has pointer to itself.
  2. Pointer stores the address of the Structure of same type.

Syntax :

struct node
{
int data;
struct node *ptr;  //Pointer to Struct node
};
  • Here ptr stores address of Structure node.
  • This is useful in Dynamic Memory Allocation and Creating Linked Lists.