打卡今日学习成果;
使用结构体表示学生的基本信息(姓名,学号,籍贯,C语言考试成绩),对其进行输入输出
/*
* 1_stu.c
* 使用结构体表示学生的基本信息(姓名,学号,籍贯,C语言考试成绩),对其进行输入输出
*
*/
#include <stdio.h>
int main(int argc, char **argv)
{
struct student
{
char name[20];
int id;
char province[20];
int C_score;
};
struct student stu; //student为结构体名,stu为结构体变量名
printf("请输入学生的姓名:");
scanf("%s",stu.name);
printf("请输入学生的学号:");
scanf("%d",&stu.id);
printf("请输入学生的籍贯:");
scanf("%s",stu.province);
printf("请输入学生的C成绩分数:");
scanf("%d",&stu.C_score);
printf("该学生的信息为:\n姓名:%s\t学号:%d\n籍贯:%s\tC成绩分数:%d\n"
,stu.name,stu.id,stu.province,stu.C_score);
return 0;
}