I am studying code examples from my professor in order to become better acquainted with linked data structures.
In our linked-list.c example the professor defines a
He is defining a temporary name for the node because he is using a well know technique to avoid writing struct node
on the declaration of each struct object.
If he would just do:
struct node {
int data;
struct node *next;
};
you would have had to use:
struct node* node;
to declare a new node. And to avoid that you would have to define later:
typedef struct node Node;
in order to be able to declare objects like the following:
Node* node;
In the end:
typedef struct node {
int data;
struct node *next;
} Node;
Is just a shortcut for struct node { ... };
in addition to typedef struct node Node;
.