Renaming Existing Types with typedef

The typedef keyword creates a new name for an existing data type. This is a convenience feature that you can use to make programs more readable. For instance, the declaration

typedef int integer;

allows you to use integer as a synonym for int.

One more practical use of typedef is to substitute a short, descriptive name for an aggregate type. For instance, the WINDOWS.H file uses typedef to create descriptive names for structures.

NOTE:

The typedef keyword doesn't create a new data type. It merely allows you to use a different name for a type that already exists.

You can also use typedef to minimize portability problems. By using typedef declarations for data types that are machine dependent, you need only change the typedef declaration if you move the program to a different operating system.