How should I check that a stream (for example a .txt file or the screen
-- std::cout ) is open and ready to receive input.
To declare the stream as an instantiation of the ofstream class,
I write
ofstream mystream("filename");
// Then, to check the stream is ready, should I say
if (!mystream){ cerr << ...}
// or should I say
if (mystream.bad()) {cerr << ...}
What are the pros and cons of both methods (if they both work)?
Thank you very much for your help.
Paul Epstein