The
typedef declaration
creates a synonym for the existing type. We use the
typedef to create an
alias name for the existing type name. The usage is of the following syntax:
typedef some_type our_new_name;
To create a new synonym for the type
int and, for example, call it
MyInteger, we type:
Now, we can use the new
MyInteger
alias in the same way we would use
int. Example:
int main(void)
{
MyInt x = 123;
printf("The value is: %d\n", x);
}
We can also create an alias for a
pointer type: