In a linked list structure, why is a pointer to the node pointer used?

Question:

When reading my teacher's slides, I had a doubt about this structure:

struct node
{
    char item;
    struct node *next;
};
typedef struct node Node;
typedef node *Lista;  

It wasn't clear to me the reason for the typedef node *Lista , as it seemed to me that there was already a pointer to the next struct . Could someone explain to me why?

Answer:

Lista is a type to organize the list, it is not the next structure, it is the first one, it is where the list starts. If every node is accessed via a pointer, how is the first node accessed? By an external pointer. That's it. There's not really a pointer to a pointer, there's just a pointer to a structure, which inside has another pointer.

Scroll to Top