望高手指点迷津尽量详细;
#include <stdio.h>
#include <stdlib.h>
struct student
{
long num;
char name[10];
floatscore1;
floatscore2;
floatscore3;
float aver;
};struct student stu[5];
void main()
{
FILE *fp; int i;
float aver(float a,float b,float c,int n)
if((fp=fopen(\"text\",\"w\"))==NULL)/*错误提示:说明语法错误*/
{
printf(\"cnanot open\\n\");
exit(0);
}
for(i=0;i<5;i++)/*警告:无效的操作代码警告:可能在I定义前使用了它错误:缺少“;”*/
scanf(\"%ld,%s,%f,%f,%f\",&stu.num,stu.name,&stu.score1,&stu.score2,&stu.score3);
for(i=0;i<5;i++)
stu.aver=aver(stu.score1,stu.score2,stu.score3,3);
fwrite(&stu,sizeof(struct student),1,fp);/*警告:可能在FP定义前使用了他*/
fclose(fp);
systemp(\"pause\");
}
float aver(float a,float b,float c,int n)
{
float aver;
aver=(a+b+c)/n;
return(aver);
} |