The typedef keyword is used to allow user defined data types based on existing data types to be defined.


Thus enabling a user created alias for an existing data type to be defined.


The syntax is:


typedef existing_type new_type ;




typedef long int spokes ;


The above shows that a new datatype called spokes has been defined as being equivalent to a long int, and the two could thereon be used interchangeably within the program it was defined in.


spokes myVar ;    is equivalent to    long int myVar ;

Leave a Reply