If I want to make a variable Point which can hold 2 doubles and I want to avoid having to write struct everytime I use it I can simply use:
typedef struct{
double x,y;
}Point;
But when I want to make a linked list the declaration must be like this:
typedef struct Node Node; // (2)
struct Node{
int d;
struct Node * next;
};
And not like this:
typedef struct{
int d;
struct Node * next;
}Node;
Why does the declaration have to be this way and why do you have to type "Node" twice, see (2).
Node *next;(which yours does not). You can just usestruct Node. Or is the intent to declare theNodetype in the first place?PointandNode? Update, oh, it's just an example, right?structa tag:typedef struct Node{ int d; struct Node * next; } Node;