新手求大佬拖走!!!救命啊

绩点不到3.6不改名 2019-06-06 08:54:09
我想把数据输入到文件中,然后再从文件中把数据显示出来,不过在把数据输入进去之前我要将数据进行计算和筛选,写了一半到数据计算这里,不会了 请大佬救我。
#include <stdio.h>
#include <stdlib.h>
struct cezhan
{
char qzd[20];
float qhe, zh, qho, hz, gc, pgc, jc; (拿来计算的数据 最后算的 jc 要比5小 )。
}cez[3];
void save(char dazuoye[], int n)
{
FILE *fp;
int i;
if ((fp = fopen("dazuoye", "wb")) == NULL)
{
printf("Can't open this file!");
exit(0);
}
for (i = 0; i < n; i++)
if (fwrite(&cez[i], sizeof(struct cezhan), 1, fp) != 1)
printf("file write error\n");
fclose(fp);
}
void show(char cz[], int n)
{
FILE *fp;
int i;
if ((fp = fopen("dazuoye", "rb")) == NULL)
fread(cz, sizeof(struct cezhan), n, fp);
for (i = 0; i < n; i++);
printf("\n%-20s%.3f%.3f%.3f%.3f%.3f\n%.0f\n", cez[i].qzd, cez[i].hz, cez[i].hz, cez[i].qho, cez[i].gc, cez[i].pgc, cez[i].jc);
fclose(fp);
}


void main()
...全文
3 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

33,311

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 新手乐园
社区管理员
  • 新手乐园社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧