cplusplus.com cplusplus.com
cplusplus.com   C++ : Reference : IOstream Library : ios : fail
- -
C++
Information
Documentation
Reference
Articles
Sourcecode
Forum
Reference
C Library
IOstream Library
Strings library
STL Containers
STL Algorithms
IOstream Library
manipulators
classes:
· filebuf
· fstream
· ifstream
· ios
· iostream
· ios_base
· istream
· istringstream
· ofstream
· ostream
· ostringstream
· streambuf
· stringbuf
· stringstream
objects:
· cerr
· cin
· clog
· cout
types:
· fpos
· streamoff
· streampos
· streamsize
ios
· ios::ios
· ios::~ios
member functions:
· ios::bad
· ios::clear
· ios::copyfmt
· ios::eof
· ios::exceptions
· ios::fail
· ios::fill
· ios::good
· ios::imbue
· ios::init
· ios::narrow
· ios::operator!
· ios::operator void*
· ios::rdbuf
· ios::rdstate
· ios::setstate
· ios::tie
· ios::widen

-

ios::fail public member function
bool fail ( ) const; 

Check if either failbit or badbit is set

The function returns true if either the failbit or the badbit is set. At least one of these flags is set when some error other than reaching the End-Of-File occurs during an input operation.

failbit is generally set by an input operation when the error was related with the internal logic of the operation itself, while badbit is generally set when the error involves the loss of integrity of the stream, which is likely to persist even if a different operation is performed on the stream.

badbit can be checked independently by calling member function bad.

Parameters

none

Return Value

true if badbit and/or failbit are set.
false otherwise.

Basic template member declaration

( basic_ios<charT,traits> )
bool fail () const;

See also

ios_base::iostate Type for stream state flags (public member type)
ios::good Check if the state of the stream is good for i/o operations. (public member function)
ios::bad Check if badbit is set (public member function)
ios::eof Check if eofbit is set (public member function)
ios::rdstate Get error state flags (public member function)
ios::clear Set error state flags (public member function)

© The C++ Resources Network, 2000-2007 - All rights reserved
Spotted an error? - contact us