Howdy,
I am wondering what is a better approach to check whether or not stream operations succeeded:

Check exceptions:

Code:
file.exceptions(ios_base::eofbit||ios_base::failbit);

try
{
   do operations on stream
}
catch (ios_base::eofbit)
{
   handle this exception
}
catch (ios_base::failbit)
{
   handle this exception
}
or just use the methods provided with streams:

Code:
do operations on stream

if (file.eof())
{
   handle eof
}

if (file.fail())
{
   handle failure
}

Normally I'd use exceptions but I'm wondering why the methods eof(), etc., were provided if exception-checking is better. I imagine the exceptions handling is much faster and creates less error-prone code....

Thanks for any info. Just curious.