<- Chameleon -> wrote:
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
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.