ptmax 2017-09-23 15:51 采纳率: 42.9%
浏览 726

数据存入数据异常急需解决

 #include"function.h"
#include<stdlib.h> 
void class_score_list1()//每门课程总分
{
    struct stu*f_str;
    f_str=read_from_file();//从文件中读入数据生成结构体数组,并返回数组第一个元素的指针 
    double s1[4];//储存每门课程的总分 
    while(1)
    {
        if(f_str->is_empty=='N')
        {
            printf("%f %f %f %f\n",f_str->score[0],f_str->score[1],f_str->score[2],f_str->score[3]);
            s1[0]+=f_str->score[0];
            s1[1]+=f_str->score[1];
            s1[2]+=f_str->score[2];
            s1[3]+=f_str->score[3];
            f_str++; 
            printf("%lf %lf %lf %lf\n",s1[0],s1[1],s1[2],s1[3]); 
        }
        else
        {
            break;
        }
    }

    return;
}

第一个printf给出的是预期的结果,但是最后一个printf出错

  • 写回答

2条回答 默认 最新

  • threenewbee 2017-09-24 00:40
    关注

    一个是f一个是lf,取决于你到底是double还是float
    read_from_file();这么写的,stu怎么定义的

    评论

报告相同问题?

悬赏问题

  • ¥50 树莓派安卓APK系统签名
  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥65 汇编语言除法溢出问题
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波