Typedef in C – Tutorialpath

C – Typedef

Typedef is a keyword used in C language to assign alternative names to existing datatypes.

typedef vs #define

#define is a C-directive which is also used to define the aliases for various data types similar to Typedef but with the following differences −

  • typedef is limited to giving symbolic names to types only where as #define can be used to define alias for values as well, you can define 1 as ONE etc.
  • typedef interpretation is performed by the compiler whereas #define statements are processed by the pre-processor.

Example:

Output:

Typedef and Pointers

Typedef can be used to give an alias name to pointers also. Here we have a case in which use of Typedef is beneficial during pointer declaration.

In Pointers * binds to the right and not on the left.

 

Leave a Reply

Your email address will not be published.