c – 无法让ifstream在XCode中工作

c – 无法让ifstream在XCode中工作,第1张

概述无论我尝试什么,我都无法使用以下代码来正常工作. ifstream inFile;inFile.open("sampleplanet");cout << (inFile.good()); //prints a 1int levelLW = 0;int numLevels = 0;inFile >> levelLW >> numLevels;cout << (inFile.good()) 无论我尝试什么,我都无法使用以下代码来正常工作.

ifstream infile;infile.open("sampleplanet");cout << (infile.good()); //prints a 1int levelLW = 0;int numLevels = 0;infile >> levelLW >> numLevels;cout << (infile.good()); //prints a 0

在第一个cout<< (infile.good());,它打印一个1,第二个打印0.这告诉我文件正确打开,但是一旦从中读入,infile就会失败.该文件具有足够多的行/字符,因此我无法通过该点尝试读取文件末尾. 文件内容:

82#level 2XXXXXXXXX......XX..X..XXX.X....XX..XX..XXXXX...XX...T..XXXX..XXX#level 1XXXXXXXXX......XX..X.XXXX.X..X.XX..XX..XX......XX^....SXXXX.^XXX
解决方法 这是一个已知的错误.来自Xcode 3.2.1的 Release Notes:

The default gcc 4.2 compiler is not
compatible with the Standard C++
library DeBUG Mode. C++ programs
compiled with Xcode 3.2 may not work
in the DeBUG configuration. To fix
this,set the Compiler Version to 4.0,
or edit the DeBUG configuration’s
Preprocessor Macros and remove the
entrIEs:
_GliBCXX_DEBUG=1 _GliBCXX_DEBUG_PEDANTIC=1

总结

以上是内存溢出为你收集整理的c – 无法让ifstream在XCode中工作全部内容,希望文章能够帮你解决c – 无法让ifstream在XCode中工作所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1000208.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-21
下一篇2022-05-21

发表评论

登录后才能评论

评论列表(0条)

    保存