Course Object Oriented Programming

Typedef

Course's Page 8 min Text by
User Image
Allan Garcia

In this class, we will study the command typedef.

Assigning synonyms to the types

The programmer can assign synonyms to the data types using the command typedef; this makes the code easier to read. To create a typedef, the following structure is used:

typedef <name> <synonym>;

For example, to assign the synonym integer to the type int, we can do it:

typedef int integer;

After that, it becomes possible to use the word integer to refer to the data type int. Thus, constructions as in the code below become legitimate:

#include <stdio.h>