Update: please see comments attached to answer for clarification.
Original post.
Besides having to write "struct" everywhere, something else of note is that using a typedef will allow you to avoid subtle syntax errors when working with pointers:
Quote:
Typedefs can also simplify declarations for pointer types. Consider this:
struct Node { int data; struct Node *nextptr; };
Using typedef, the above code can be rewritten like this:
typedef struct Node Node; struct Node { int data; Node *nextptr; };
In C, one can declare multiple variables of the same type in a single statement, even mixing pointer and non-pointers. However, one would need to prefix an asterisk to each variable to designate it as a pointer. In the following, a programmer might assume that errptr was indeed a Node *, but a typographical error means that errptr is a Node. This can lead to subtle syntax errors.
struct Node *startptr, *endptr, *curptr, *prevptr, errptr, *refptr;
By defining a Node * typedef, it is assured that all the variables will be pointer types.
typedef struct Node *NodePtr; ... NodePtr startptr, endptr, curptr, prevptr, errptr, refptr;
typedefsimply defines an alias for a certain type. If that type is a structure, an enumeration or something else doesn't matter.typedefwithout a typedef-name? Is this about the purpose oftypedefin general? Is this about nameless struct types? There's no way to say whether the OP's examples are built that way deliberately or by mistake. Please, clarify the question.