1.typedef用于给已有的类型名指定一个新的类型名
typedef int INTEGER;
typedef float REAL;
INTEGER i,j; //等价于:int i,j;
REAL x,y; //等价于:float x,y;
/*========================================================*/
typedef struct student
{
char *name;
char *id;
float score;
}STU;
STU s1,s2; //等价于:struct student s1,s2;
/*========================================================*/
typedef int ARR[100];
ARR a,b,c; //等价于:int a[100],b[100],c[100];
/*=========================================================*/
2.typedef和#define本质上不同
(1).#define是在预编译时处理的,只能作简单的字符替换
(2).typedef是在编译时处理的,并不是作简单的字符替换
【注】当不同源文件中用到同一类型数据时,常在一个单独的文件中用typedef声明一些数据类型,用到的时候用#include命令把它们包含进来即可。