#include<stdio.h>
struct Student //学生结构
{
char name[10];
char sex[10];
char age[10];
}student1={"苏墨","女","18"}; //定义变量并设置初始化
int main()
{
struct Student student2={"志强","男","19"}; //定义变量并设置初始化
printf("第一个学生的资料为:\n");
printf("姓名:%s\n",student1.name);
printf("性别:%s\n",student1.sex);
printf("年龄:%s\n",student1.age);
printf("第二个学生的资料为:\n");
printf("姓名:%s\n",student2.name);
printf("性别:%s\n",student2.sex);
printf("年龄:%s\n",student2.age);
return 0;
}
2021-12-15 结构体类型变量的初始化栗子
最新推荐文章于 2022-11-21 14:20:40 发布