结构体类型的定义有三种:
一般
struct student{
int num;
int age;
double score;
char name[100];
};
struct student person1,person2;
==
struct student{
int num;
int age;
double score;
char name[100];
}person1,person2;
其中,struct是C语言的关键字,而struct student是person1,person2的数据类型,与int,double,float,char同一地位。
宏定义
#define Stu struct student;
Stu{
int num;
int age;
double score;
char name[100];
}person1,person2;
取别名
typedef struct student{
int num;
int age;
double score;
char name[100];
}Stu;
Stu person1,person2;
方法2,3大同小异,都是用一种符号取代原有的数据类型,如struct student,并没有产生新的数据类型