作用是作为一种数据类型定义一个新名字
这里的数据类型包括内部数据类型(int,char等)和自定义的函数struct等。
和struct来陪匹配为了代码编写简洁
和普通类型匹配,通过名字来获取一些信息
#include <stdio.h>
#include <stdlib.h>
typedef unsigned char u_int8; //(0-255) 无符号的整型8位
typedef unsigned short int u_int16; // 无符号的整型16位
typedef unsigned int u_int32;
typedef struct Student //把 他 叫成 STU, *PSTU
{
int score;
char *name;
}STU,*PSTU;
int main()
{
u_int8 data1 = 10;
u_int16 data2 = 20;
u_int32 data3 = 40;
printf("%d\n%d\n%d\n",data1,data2,data3);
STU stu1;
stu1.score = 100;
printf("score = %d\n",stu1.score);
PSTU pstu;
pstu = (PSTU)malloc(sizeof(STU));
pstu->score = 99;
printf("score = %d\n",pstu->score);
system("pause");
return 0;
}