bad and fail of steam

Joined
Feb 12, 2008
Messages
108
Reaction score
0
Hello everyone,


Two questions,

1. Confused about what is the differences between bad and fail. This what Bjarne's comments in his book, but I do not quite understand and it is appreciated if you could share some best practices of the differences and when to use them.

--------------------
The difference between the states fail() and bad() is sutle. When the state is fail() but not also bad(), it is assumed that the stream is uncorrupted and that no characters have been lost. When the state is bad(), all bets are off.
--------------------

2. when do you prefer to use bad()/fail() and when do you prefer to use setting exceptions (std::ios::badbit or std::ios::failbit or both).


thanks in advance,
George
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top