0

与 C 合作。

好的,所以这可能是显而易见的,但由于某种原因,我的程序只会从 .dat 输入文件中打印一定数量的值,而不是打印所有值。这是代码:

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{

int N = 0;
int j;
float i;

const char Project_Data[] = "FloatValues.dat";

FILE *input = fopen(Project_Data, "r");

if(input != (FILE*) NULL)
{
    while(fscanf(input, "%e", &i) == 1)
    {
        printf("%e\n",i);
        ++N;
    }
    printf("\t The number of values in this file is: %d\n", N);

    fclose(input);
}
else
    printf("Input file could not be read.\n");

return(0);
}

是的,所以大约有 100000 个值要打印,但我似乎只能得到 20000 个。文件中的值是按顺序排序的,编译器似乎只在文件底部附近开始打印,大约 80000 或所以价值观。

有人知道我哪里出错了吗?

4

0 回答 0