confused about ios::failbit

G

Guest

What is the difference between ios::failbit and ios::badbit?
When happen the first and when the second?

I try several circumstances to describe when every flag occurs but only ios::failbit I have.

So, when ios::badbit occurs?
If I have a damaged media what occurs?

Is this patform / compiler depended?

Thanks!
 
K

Kevin Goodsell

What is the difference between ios::failbit and ios::badbit?
When happen the first and when the second?

I try several circumstances to describe when every flag occurs but only ios::failbit I have.

So, when ios::badbit occurs?
If I have a damaged media what occurs?

Is this patform / compiler depended?

Thanks!

From Josuttis's "The C++ Standard Library":

The difference between failbit and badbit is basically
that badbit indicates a more fatal error:

* failbit is set if an operation was not processed correctly
but the stream is generally OK. Normally this flag is set
as a result of a format error during reading. For example,
this flag is set if an integer is to be read but the next
character is a letter.

* badbit is set if the stream is somehow corrupted of if data
is lost. For example, this flag is set when positioning
a stream that refers to a file before the beginning of a
file.

failbit is also set in concert with eofbit on the first attempt to read
past the end of the stream.

-Kevin
 

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,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top