#include
struct score
{
int id;
char name[50];
float chinese;
float math;
float english;
float ave;
float sum;
};
#define n 16
int main()
{
int i,j;
struct score stu[n+1];
FILE *fp;
fp=fopen("E:\\stuScores.txt","rt");
if (fp==NULL)
{
printf("无法打开文件!\n");
return 0;
}
for(i=0;i<16;i++)
{
fscanf(fp,"%d",&stu[i].id);
fscanf(fp,"%s",stu[i].name); ///-----------
fscanf(fp,"%f",&stu[i].chinese);
fscanf(fp,"%f",&stu[i].math);
fscanf(fp,"%f",&stu[i].english) ;
stu[i].sum=stu[i].chinese+stu[i].id+stu[i].english;
stu[i].ave=stu[i].sum/3;
if ( feof(fp) )
break;
}
fclose(fp);
j=i;
for(i=0;i{
printf("%d\t",stu[i].id);
printf("%s\t",stu[i].name);
printf("%f\t",stu[i].chinese);
printf("%f\t",stu[i].math);
printf("%f\t",stu[i].english) ;
printf("%f\t%f\n", stu[i].sum, stu[i].ave );
}
return 0;
}
哪里出了问题、详细说明一下、