想知道输出结果为什么只有1,旁边的调试框中的name为什么是等于117‘g’呢??还有结构体的int score[3]是让我输入三个成绩的意思吗?也就是每个人有三门课的成绩
#include<stdio.h>
struct grade
{
int num;
char name;
int score[3];
};
struct grade student[5];
char print(struct grade student[],int a)
{
printf("输出结果为:\n");
for(int i=0;i<a;i++)
{
printf("%d ",student[i].num);
printf("%s",student[i].name);
printf("%d %d %d",student[i].score[i],student[i].score[i+1],student[i].score[i+2]);
printf("\n");
}
}
int main()
{
printf("请输入记录:");
for(int i=0;i<5;i++)
{
scanf("%d",&student[i].num);
scanf("%s",&student[i].name);
scanf("%d",&student[i].score[i]);
scanf("%d",&student[i].score[i+1]);
scanf("%d",&student[i].score[i+2]);
}
print(student,5);
return 0;
}