#include
#include
struct stu
{
float english;
float computer;
float math;
char name[20];
}a[20],*p;
int main()
{
FILE *fp1,*fp2;
float avg;
int i;
p=a;
if((fp1=fopen("file2.dat","rt"))==NULL)
{
printf("failed to open file2.dat!");
exit(1);
}
for(i=0;i
fscanf(fp1,"%s%d%d%d\n",p->name,&p->english,&p->computer,&p->math);
p=a;
fclose(fp1);
if((fp2=fopen("file3.dat","wt"))==NULL)
{
printf("failed to open file3.dat!");
exit(1);
}
printf("个人平均分大于80分学生信息如下:\n");
printf("%-8s%-8s%-8s%-8s\n","姓名","英语","计算机","数学");
for(i=0;i
{
avg=(p->english+p->english+p->math)/3;
if(avg>=80)
{
printf("%-8.2f%-8.2f%-8.2f\n",p->english,p->computer,p->math);
fprintf(fp2,"%-8.2f%-8.2f%-8.2f\n",p->english,p->computer,p->math);
}
}
fclose(fp2);
return 0;
}
fscanf这里为什么我无法写入数组,弄了一个下午,头都晕了
C语言文件读写问题..........
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- 善莫大焉 2016-06-26 09:36关注
q 11,22,33
w 44,55,66
e 45,32,45
r 78,55,69
t 78,55,87
y 23,45,98
u 12,56,88
i 89,65,32
o 98,44,55
p 65,32,12
a 12,45,56
s 88,99,56
d 56,78,56
f 45,78,56
g 56,55,78
h 56,77,89
j 56,55,78
k 56,56,88
l 22,33,55
z 45,55,66
这是我的file1.dat文件解决 无用评论 打赏 举报
悬赏问题
- ¥15 安装svn网络有问题怎么办
- ¥15 Python爬取指定微博话题下的内容,保存为txt
- ¥15 vue2登录调用后端接口如何实现
- ¥65 永磁型步进电机PID算法
- ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
- ¥88 找成都本地经验丰富懂小程序开发的技术大咖
- ¥15 如何处理复杂数据表格的除法运算
- ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
- ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
- ¥15 latex怎么处理论文引理引用参考文献