bad [C++ Reference]
Keywords: io,bad
Date: 2009-03-09T12:14:20-0700

## bad

Syntax:

        bool stream::bad();

The bad() function returns true if a fatal error with the current stream has occurred, false otherwise.

Note: fatal errors do not normally occur. Even a failure to open a file is not a fatal error.

Related Topics: clear, eof, exceptions, fail, good, rdstate

Stream states:

- if (s): The previous operation was successful (a shorthand for !s.fail()).
- if (s.fail()): The previous operation failed.
- if (s.eof()): Reading past the end has been attempted.
- if (s.bad()): Stream state is undefined; the stream can no longer be used.
- if (s.good()): None of bad/eof/fail are set.