关于结构体的问题。。。很疑惑啊!
程序代码:此程序功能是:输入两个学生的学号、姓名、成绩,输出成绩高的学号、姓名、成绩。
错误信息为:
error C2224: left of '.st1' must have struct/union type
error C2224: left of '.st2' must have struct/union type
# include <stdio.h>
int main (void)
{
struct Student
{
int num;
char name[21];
int score;
};
struct Student st1,st2;
scanf ("%d %s%d",&st1.num,st1.name,&st1.score);
scanf ("%d %s%d",&st2.num,st2.name,&st2.score);
if (st1.score>st2.score)
{
printf("num is %d\n name is %s\n score is %d",
st1.num,st1.name.st1.score);
}
else if (st1.score<st2.score)
{
printf("num is %d\nname is %s\nscore is %d",
st2.num,st2.name.st2.score);
}
else
{
printf("num is %d\nname is %s\nscore is %d",
st1.num,st1.name.st1.score);
printf("\n");
printf("num is %d\nname is %s\nscore is %d",
st2.num,st2.name.st2.score);
}
getch();
}






