结构体定义形式三种:
1.间接定义
struct
student
{
int num;
char name[20];
};
struct student[2];
2.直接定义
struct
student
{
int num;
char name[20];
}stu[2];
3. 无名定义
struct
{
int num;
char name[20];
}stu[2];
结构体数组初始化:
1,顺序初始化:
struct stu[]={200101,"xiaoming",200102,xiaoqiang,200105,"xiaohua"};
2.分行初始化: 添加大括号
struct stu[]={ {200101,"xiaoming"}, {200102,xiaoqiang},{200105,"xiaohua"}};
总结:
上面红色字样初始化是对的。