0
由於ifile
的內容與標籤不匹配,我的代碼陷入了無限循環。無法將std :: ifstream與std :: string進行比較
在調試過程中,我注意到ifile
的內容是整個文件的字符串。
void Experiment::read_moveTo(ifstream* ifile, string label) {
string temp;
while (temp.compare(label) != 0 and ifile) {
*ifile >> temp;
if (ifile->eof()) {
cout << "Read error: Could not find label '"
<< label << "' while reading parameter file '"
<< parameterFile << "'" << endl;
exit(0);
}
}
}
我希望ifile
內容與標籤匹配並退出指向該地址。
我們需要比此更多的信息。向我們顯示文件的內容。 – 0x499602D2
另外,告訴我們如何創建流指針並將其發送給方法。 – 0x499602D2