previous | start | next

Using typedef to name types

Examples of typedef declarations that give new names to existing type names or to type expressions:

 typedef int id; /* defines id as a type to be the same as int */
 id n;           /* declares n to be of type id (i.e. an int)  */
   
typedef struct {
  char c1;
  int n;
  char c2;
  double x;
} s1_t;

s1_t s;  /* Defines s to be of type s1_t (a struct) */


previous | start | next