编辑已解决...对多个文件使用相同的ifstream显然不是一个好主意。
我刚买了一台新的笔记本电脑,并将我的C ++项目转移到新电脑上,我突然遇到了从Code :: Blocks读取文本文件的问题......我不知道为什么。
旧笔记本电脑运行32位操作系统,而新笔记本电脑运行64位操作系统。我不知道这是否会影响任何事情。
以下是不再有效的代码部分:
ifstream myfile;
//edit: a different file is read here, in exactly the same manner as below
//when I comment it out, the following section works as it's meant to...
//what am I doing wrong that they won't work successively
myfile.open("version.txt");
if (myfile.is_open()) {
out("This message displays...");
//OK so apparently 'eofbit' is thrown here...but the file has content in it?
while (myfile.good()) {
out("This message doesn't, when it should...");
getline(myfile,version_info);
}
myfile.close();
}
编辑:'out'只是一个显示消息的自定义脚本,顺便说一句。