Loading, please wait...

typedef

The keyword typedef provides a mechanism for creating synonyms (or aliases) for previously defined data types. Names for structure types are often defined with typedef to create shorter type names.

 

For example, the statement

typedef struct card Card;

defines the new type name Card as a synonym for type struct card. C programmers often use typedef to define a structure type, so a structure tag is not required.

 

For example, the following definition

typedef struct {

char *face;

char *suit;

} Card;

creates the structure type Card without the need for a separate typedef statement.