Tuesday, 5 June 2018

Typedef



typedef is a reserved keyword in the C and C++ programming languages. It is used to create an alias name for another data type.



Limitations :-


  • typedef is limited to giving symbolic names to types only, where as #define can be used to define alias for values as well, e.g., you can define 1 as ONE, 3.14 as PI, etc.

  • define should not be terminated with semicolon, but typedef should be terminated with semicolon.

  • typedef follows the scope rule which means if a new type is defined in a scope (inside a function), then the new type name will only be visible till the scope is there.