dcsimg
Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: C++
Expertise: Beginner
Oct 18, 2000

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Checking the State of a Stream

The iostream family of classes provides the following member functions and operators for checking the stream's state:

 
bool good() // returns true if no error flag is set
bool eof() // returns true if eofbit is set
bool fail() // returns true of failbit or badbit is set
bool bad()  // returns true if badbit is set
bool operator!() // as fail()
operator void*() // returns null if fail() is true

In other words, good() takes all flags into account, including the eofbit, whereas fail(), operator!() and operator void*() ignore eofbit. Thus, if you wish to check whether the stream is in a state of error, use fail(), operator!() or operator void*(). On the other hand, to check a failure of input operations, call the member function good().

Danny Kalev
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date