Hi!
I've got bit of a problem here:
Code:
.......
while(!sfs.eof())
{
Efs.open("Elib.txt", ios::in);
.......
Efs.seekg(0);
cout<<Efs.tellg()<<endl;
while(!Efs.eof())
{
char* Ewrds = new char[20];
Efs.getline(Ewrds, 20, '\n');
if(!strcmp(wrdsrc, Ewrds))
{
found=true;
break;
}
}
Efs.close();
if(found)
{
cout<< "Found";
}else
{
cout<< "Not Found";
}
}
......
In the above code, when strcmp() returns zero and the inner while loop breaks before the Efs reachs it's eof, all seems to work fine. But when the inner loop iterate until the eof is found, in the next iteration of the outer loop, tellg() returns (-1) and the inner while’s efo check returns non-zero. Could anyone please point out how to fix this?
Thanks.