My code set std::failbit when it reach eof and exception is thrown how can i skip eof exception
In catch block i check and skip if exception is because of eof but its not good.
please suggest how can i skip eof exception in below code
std::ifstream in
std::string strRead;
in.exceptions ( std::ifstream::failbit | std::ifstream::badbit );
try
{
while (getline( in,strRead))
{
//reading the file
}
catch(std::ifstream::failure & exce)
{
if(! in.eof()) // skip if exception because of eof but its not working?
{
cout<<exce.what()<<endl;
return false;
}
}
catch(...)
{
cout("Unknow exception ");
return false;
}