0
我想从文件中读取每个单词。它打开了文件,但它并没有进入while循环不从文件中读取
string x;
ifstream inFile ("test.txt");
if (!inFile) {
cout << "Unable to open file";
exit(1); // terminate with error
}
while (inFile >> x) {
cout << "hi" << endl;
}
cout << "hsiwsdsc" << endl;
inFile.close();
什么是文件的内容和你的输出是什么? – 2013-02-10 15:54:40
这和Xcode有什么关系? – 2013-02-10 15:54:49
尝试打印'x'来查看它是否读取任何内容。 – jrok 2013-02-10 15:59:09