feof(file) 在 macOS 的 cLion 中不会终止循环

feof(file) does not terminate loop in cLion for macOS

提问人:Fady Nabil Yacoub 提问时间:10/19/2017 更新时间:10/19/2017 访问量:81

问:

为什么这段代码会导致 cLion 上的无限循环,而在 Xcode 上打开项目时,它会正常工作并在 EOF 上找到时终止?

       while (!feof(file)) {
        fscanf(file, "%d", &number);
        printf("%d\t",number);
    }
macOS While-loop Clion Feof

评论

0赞 Mark Setchell 10/19/2017
很难说你的代码是不完整的,你没有给出你用什么选项编译它......
0赞 Fady Nabil Yacoub 10/19/2017
这只是在 main 函数中尝试从 .txt 文件中读取由制表符分隔的整数。
0赞 Mark Setchell 10/19/2017
问题应该包括一个最小的、完整的代码示例,可以编译和测试。您使用的编译器、编译/链接选项以及您包含的头文件都会有所不同。

答: 暂无答案