This is some code I wrote to check a string's
presence in a file:
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;
}
it is sure that the string being searched lies in the first column of the optab1.txt
and in total there are two columns in the optab1.txt
for every row.
Now the problem is that no matter what string is being passed as the parameter s
to the function always returns false. Can you tell me why this happens?