![]() |
#2
ID不见了2016-05-13 15:27
|

#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;
}
#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 *'