【发布时间】:2015-10-15 15:47:59
【问题描述】:
我已经从文本文件中读取了这些行,我想检查该行是否包含 $ 符号。
这就是我目前得到的:
int main() {
ifstream data_store;
string line;
data_store.open("c:\\test.txt");
while (!data_store.eof())
{
getline(data_store, line);
if (line.find("$"))
cout << "1: " << line << endl;
}
data_store.close();
system("PAUSE");
return 0;
}
此外,我如何将它们输出到文件中?
【问题讨论】:
-
您对查找部分有疑问吗?
-
然后呢?是有问题还是你只是问如何输出到文件?
-
我不使用 c++ 我不知道它是将整个字符串与“$”进行比较还是在 line.find 函数中搜索它
-
使用
std::ofstream写入文件。 -
"它没有找到带有 $ 的行" - 嗯?你有错误,但这根本不是真的。
标签: c++ filestream