io:good

C++ Reference

good

Syntax:

    #include <fstream>
    bool good();

The function good() returns true if no errors have occurred with the current stream, false otherwise.

Related Topics: bad, clear, eof, exceptions, fail, 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.