User-Defined Types

The typedef keyword allows you to create user-defined types, which are synonyms for existing data types. User-defined types can make your program more readable. For example, a type called string may be easier to understand than a type called char *.

A simple typedef declaration is shown below. The name of an existing type (long int) is followed by the synonym income.

typedef long int income;

Once you have created a new type name, you can use it wherever the original type name could be used:

income net_income, gross_income;

In the example above, the variables net_income and gross_income are of type income, which is the same as long int.