C 一个烫烫烫的问题

Scorpion_xyt Scorpion_xyt 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include <stdio.h>
#include <memory.h>
struct student
{
int num;
char name[10];
float score1;
float score2;
float score3;
float aver;
};
main()
{
int i,nu;
float sc1,sc2,sc3;
char na[10];
struct student st[1];
FILE *fp;
if((fp=fopen("E:\student.txt","w+"))==NULL)
{
printf("can not open file\n");
exit(0);
}
setbuf(fp,NULL);
for(i=0;i<1;i++)
{
scanf("%d%s%f%f%f",&nu,&na,&sc1,&sc2,&sc3);
fprintf(fp,"%d %s %f %f %f %f",nu,na,sc1,sc2,sc3,(sc1,sc2,sc3)/3);
fflush(fp);
}
for(i=0;i<1;i++)
{
fscanf(fp,"%d%s%f%f%f%f%f",&st[i].num,&st[i].name,&st[i].score1,&st[i].score2,&st[i].score3,&st[i].aver);
}
for(i=0;i<1;i++)
{
printf("%d %s %.2f %.2f %.2f %.2f",st[i].num,st[i].name,st[i].score1,st[i].score2,st[i].score3,st[i].aver);
}
fclose(fp);
}



请求指点,为什么输出的数据都不正确?应该怎么解决呢?
...全文
评论 6
收藏 已收藏
分享
返回顶部
Scorpion_xyt
C语言 70,039 成员 243,237 内容