Typedef struct tagmystruct
{
Int inum;
Long llength;
} Mystruct;
The above tagmystruct is the identifier, and mystruct is the variable type (equivalent to (INT, Char, etc )).
This statement actually completes two operations:
1) define a new structure type
Struct tagmystruct
{
Int inum;
Long llength;
};
Analysis: tagmystruct is called "tag", that is, "tag". It is actually a temporary name. Whether or not the typedefstruct keyword and tagmystruct constitute this structure type, this structure exists.
We can use struct tagmystruct varname to define variables, but note that it is incorrect to use tagmystruct varname to define variables, Because struct and tagmystruct can be combined to represent a structure type.
2) typedef is named mystruct for the new structure.
Typedef struct tagmystruct mystruct;
Therefore, mystruct is actually equivalent to struct tagmystruct. We can use mystruct varname to define variables.
2.
Typedef struct tagmystruct
{
Int inum;
Long llength;
} Mystruct;
In C, there are two methods to apply for Structure Variables after this declaration:
(1) variable name of struct tagmystruct
(2) mystruct variable name
In C ++
(1) variable name of struct tagmystruct
(2) mystruct variable name
(3) tagmystruct variable name
Typedef struct usage