#include<stdio.h>
typedef struct STU
{
char num[7];
char name[16];
struct DATE
{
int year;
int month;
int day;
}birthday;
struct RECORD
{
int a;
int b;
int c;
int d;
}record;
}stu;
void main()
{
int n,i;
scanf("%d",&n);
for(i = 0; i < n; i++)
{
scanf("%s %s %d%d%d %d%d%d",&stu[i].num,&stu[i].name,&stu[i].birthday.year,&stu[i].birthday.month,&stu[i].birthday.day,&stu[i].record.a,&stu[i].record.b,&stu[i].record.c);
/* scanf("%s",&stu[i].name);
scanf("%d%d%d",&stu[i].birthday.year,&stu[i].birthday.month,&stu[i].birthday.day);
scanf("%d%d%d",&stu[i].record.a,&stu[i].record.b,&stu[i].record.c);*/
}
int rr[n];
for(i = 0; i < n; i++)
{
rr[i] = a*0.2 + b*0.3 + c*0.5;
}
printf("num name birthday s1 s2 s3 sum\n");
for(i=0 ; i<n; i++)
{
printf("%-10s",stu[i].num);
printf("%-10s",stu[i].name);
printf("%d/%2d/%-4d",stu[i].birthday.year,stu[i].birthday.month,stu[i].birthday.day);
printf("%-4d\n",rr[i]);
}
}
错误信息如下;
T.CPP
e:\c\l\t.cpp(33) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(33) : error C2228: left of '.num' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(33) : error C2228: left of '.name' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(33) : error C2228: left of '.birthday' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2228: left of '.year' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(33) : error C2228: left of '.birthday' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2228: left of '.month' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(33) : error C2228: left of '.birthday' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2228: left of '.day' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(33) : error C2228: left of '.record' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2228: left of '.a' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(33) : error C2228: left of '.record' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2228: left of '.b' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(33) : error C2228: left of '.record' must have class/struct/union type
e:\c\l\t.cpp(33) : error C2228: left of '.c' must have class/struct/union type
e:\c\l\t.cpp(39) : error C2057: expected constant expression
e:\c\l\t.cpp(39) : error C2466: cannot allocate an array of constant size 0
e:\c\l\t.cpp(39) : error C2133: 'rr' : unknown size
e:\c\l\t.cpp(43) : warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
e:\c\l\t.cpp(50) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(50) : error C2228: left of '.num' must have class/struct/union type
e:\c\l\t.cpp(51) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(51) : error C2228: left of '.name' must have class/struct/union type
e:\c\l\t.cpp(52) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(52) : error C2228: left of '.birthday' must have class/struct/union type
e:\c\l\t.cpp(52) : error C2228: left of '.year' must have class/struct/union type
e:\c\l\t.cpp(52) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(52) : error C2228: left of '.birthday' must have class/struct/union type
e:\c\l\t.cpp(52) : error C2228: left of '.month' must have class/struct/union type
e:\c\l\t.cpp(52) : error C2275: 'stu' : illegal use of this type as an expression
e:\c\l\t.cpp(20) : see declaration of 'stu'
e:\c\l\t.cpp(52) : error C2228: left of '.birthday' must have class/struct/union type
e:\c\l\t.cpp(52) : error C2228: left of '.day' must have class/struct/union type
执行 cl.exe 时出错.