Reputation:
Is the following
typedef struct node {
int data;
struct node* next;
} node;
the only way one can define a struct
so that one needn't write out struct
inside
of the rest of the program when using it?
I.e. by the above struct
the following works just fine:
node* head = NULL;
But, is there another way to express the same struct
that is generally considered better?
Upvotes: 0
Views: 496
Reputation: 1975
No. You could also do:
struct node {
int data;
struct node* next;
};
typedef struct node node;
'Better' isn't really a qualifier that can be applied to these; to my knowledge there is no advantage to one or the other.
Upvotes: 2