【发布时间】:2021-10-14 03:59:08
【问题描述】:
我想在文本文件中搜索一个字符串。我使用 CodeBlocks 作为 IDE。
这是我的代码:
string strLineToRead;
ifstream ifFile;
ifFile.open("FileToRead.txt");
while(strLineToRead.find("blabla") == string::npos)
{
getline(ifFile, strLineToRead);
}
ifFile.close();
return 0;
【问题讨论】:
-
你应该学习如何调试你的代码。
-
在文件不包含字符串“blablah”的情况下,该程序将如何摆脱
while循环?