bad and fail of steam

Discussion in 'C Programming' started by George2, Feb 18, 2008.

  1. George2

    George2

    Joined:
    Feb 12, 2008
    Messages:
    108
    Likes Received:
    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
     
    George2, Feb 18, 2008
    #1
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.