帮我看看这个程序有没有错误的地方 谢谢各位 !!!
#include <stdio.h>
main()
{ FILE *fp;
struct st
{ int number;
char name[20];
float math;
float computer;
float total;
} student;
int i,j;
if((fp=fopen("score","wb+"))==NULL)
{ printf("file open error\n");
exit(0);
}
for(i=0;i<30;i++)
{ scanf("%d,%20s,%f,%f",
&student.number,student.name,&student.math,&student.computer);
student.total=student.math+student.computer;
j=student.number-1;
fseek(fp,(long)j*sizeof(struct st),SEEK_SET);
if(fwrite(&student,sizeof(student),1,fp)!=1) printf("write file error\n");
}
fclose(fp);
}
[此贴子已经被作者于2004-07-26 17:36:19编辑过]