![]() |
typedef | Keyword |
Keyword Index |
Creates a new type.
The syntax for defining a new type is
typedef type-definition identifier;This statement assigns the symbol name identifier to the data type definition type-definition. For example,
typedef unsigned char byte; typedef char str40[41]; typedef struct {float re, im;} complex; typedef char *byteptr; typedef int (*fncptr)(int);After these definition, you can declare
byte m, n; str40 myStr; complex z1, z2; byteptr p; fncptr myFunc;with the same meaning as you declare
unsigned char m, n; char myStr[41]; struct {float re, im;} z1, z2; char *p; int (*myFunc)(int);User defined types may be used at any place where the built-in types may be used.