//结构体练习:定义一个结构体表示学生
//学生属性有:姓名,年龄
//要求:把三个学生信息放入到数组当中,并遍历数组
#include<stdio.h>
struct student {
char name[100];
int age;
};
int main()
{
struct student stu1 = { "zhangsan",23 };
struct student stu2 = { "lisi",24 };
struct student stu3 = { "wangwu",25 };
struct student stuArr[3] = {stu1,stu2,stu3};//数据类型 数组名字[数据个数]
for (int i = 0; i < 3; i++)
{
struct student temp = stuArr[i];
printf("学生得信息为:姓名%s,年龄%d\n", temp.name, temp.age);
}
return 0;
}