【发布时间】:2016-06-02 04:15:29
【问题描述】:
我正在尝试将矩阵打印到 csv 中。其中的 arg[2] 是文件名,我可以验证它是否正常工作,因为它会生成文件但不会填充它。我确实关闭了文件并尝试刷新它,但它不起作用。
// Open the output/second file and write the contents of truncated DCT matrix into it
outputfp = fopen(argv[2], "w");
if (outputfp == NULL) {
fprintf(stderr, "Can't open output file %s!\n", argv[2]);
exit(1);
}
double hold = 0;
printf("test\n");
for (i = 0, i < idx; i++;) {
for (j = 0, j < ARRAY_WIDTH; j++;) {
hold = test_write[i][j];
fprintf(outputfp, "%.61f", hold);
if (j != ARRAY_WIDTH) {
fprintf(outputfp, ",");
}
else {
//continue;
}
fflush(outputfp);
}
}
fclose (outputfp);
return 0;
}
【问题讨论】: