- 定义一种类型的别名
typedef int INT;
INT a = 5; //相当于INT a = 5
- 定义一种结构体的别名
typedef struct my_tmp_struct{
int a;
int b;
}MTS;
MTS p1; // 结构体my_tmp_struct简写为MTS
- 定义一种数组的别名
typedef int INT_ARRAY_10[10];
typedef int INT_ARRAY_20[20];
INT_ARRAY_10 a,b,c,d;
INT_ARRAY_20 e;
//其中INT_ARRAY_10和INT_ARRAY_20为新的类型名,10 和20 为数组的长度。a,b,c,d均是长度为10的整型数组,e是长度为20的整型数组。
- 定义一种指针的别名
typedef char * STRING;
STRING csName={“Jhon”};