© Mikael Olsson 2019
Mikael OlssonModern C Quick Syntax Referencehttps://doi.org/10.1007/978-1-4842-4288-9_11

11. Typedefs

Mikael Olsson1 
(1)
Hammarland, Länsi-Suomi, Finland
 
An alias for a type can be created using the typedef keyword followed by the type and alias name. By convention, uppercase letters are commonly used for these definitions.
typedef unsigned char BYTE;
Once defined, the alias can be used as a synonym for its specified type.
BYTE b; /* unsigned char */
typedef does not only work for existing types, but can also include a definition of a user-defined type—such as a struct, union, or enum. This can make a complex type easier to understand.
typedef struct { int points; } score;
score a, b, c;
a.points = 10;

If used properly, a type alias can simplify a long or confusing type name, making the code easier to understand. Another benefit they provide is the ability to change the definition of a type from a single location, which can help make a program more portable.