string's
这是我为检查文件是否存在而编写的一些代码:
bool aviasm::in1(string s)
{
ifstream in("optab1.txt",ios::in);//opening the optab
//cout<<"entered in1 func"<<endl;
char c;
string x,y;
while((c=in.get())!=EOF)
{
in.putback(c);
in>>x;
in>>y;
if(x==s)
return true;
}
return false;
}
可以确定要搜索的字符串位于 的第一列,optab1.txt
并且每一行总共有两列optab1.txt
。现在的问题是,无论将什么字符串作为参数传递s
给函数总是返回false。你能告诉我为什么会这样吗?