bscodinglab

Typedef

  • The C programming language provides a keyword called typedef, which you can use to give a type a new name. Following is an example to define a term BITE for one-byte numbers −

            for example :-    typedef unsigned char BITE;

After this type definition, the identifier BITE can be used as an abbreviation for the type unsigned char, for example :-    BITE  b1, b2;

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, q., you can define 1 as ONE etc.
  • typedef interpretation is performed by the compiler whereas #define statements are processed by the pre-processor.