typedef 关键字
typedef为C语言的关键字,作用是为一种数据类型定义一种新的名字。数据类型包括内部数据类型(int char等 )和自定义的数据类型(struct 等)。
匹配
1、和普通类型匹配,通过名字来获取一些信息。
2、和 struct 来匹配为了代码编写简介。
和普通的类型匹配
在单片机开放,寄存器位 8位 16位 32位
typedef unsigned char u_int8;
typedef unsigned short int u_int16;
typedef unsigned int u_int32;
和struct来匹配
typedef struct
{
int score;
char *name;
}STU,*PSTU;
int main()
{
STU stu1; // STU == struct student
PSTU pstu;
pstu = (PSTU)malloc( sizeof(STU) );
pstu->score=99;
printf("score2=%d\n", pust->score);
}