Akash Bera Akash Bera - 3 months ago 9
C Question

what is self-referencing pointer in C?

struct LinkedList
{
int data;
struct LinkedList *next;
};


In the above code,There is a self referencing pointer. How it works?

Answer

A self-referential pointer which points to the address of whatever it is a part of. So for example,

typedef struct node {     
   char data[30]; 
   struct node *this; 
   struct node *next; 
} Node; 

*this is a self-referential pointer if it is assigned to whatever is applied to.

,and

Clearly a Cell cannot contain another cell as it becomes a never-ending recursion.

However a Cell CAN contain a pointer to another cell.

Refer this post as well.