{
int id;
char name[20];
char sex;
int age;
float score;
char addr[30];
};
注意:student是数据类型,不是变量(等同于int float,char这些数据类型)是用来定义其他变量的。它属于组合数据类型;
如何定义结构体变量:
1 直接用已声明的结构体类型定义变量名
student studen1, student2;
( 结构体类型名) (结构体变量名)
对比:int a;(student 相当与 int)
2在声明类型的同时定义变量
struct student
{
int id;
char name[20];
char sex;
int age;
float score;
char addr[30];
}yp1,yp2;
第一种:只有结构体定义
