关于C++查找文本字符串的问题
我想从已有文本中查找关键字,并输出该关键字所在的整行文字,为什么会出现这个错误啊?请问下这个错误是怎么回事啊啊?代码如下:
程序代码:#include<iostream>
#include<fstream>
#include<string>
using namespace std;
int main()
{
ifstream ist("L:\\1.txt");
if(!ist)
{
cout<<"打开失败..."<<endl;
return 0;
}
string line;
char *s;
while(!ist.eof())
{
getline(ist,line);
s=strstr(line,"22");
if(s!=NULL)
{
cout<<line<<endl;
}
}
ist.close();
return 0;
}这是错误信息:
L:\Microsoft Visual Studio\MyProjects\C++\yes\test.cpp(19) : error C2664: 'strstr' : cannot convert parameter 2 from 'class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> >' to 'const char *'


