Akash Bera Akash Bera - 1 month ago 4x
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?


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.


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.