public member function
<ios> <iostream>
std::basic_ios::rdstateGet error state flags
Returns the current internal error state flags of the stream.The internal error state flags are automatically set by calls to input/output functions on the stream to signal certain errors.
true
false
false
false
goodbit eofbit End-of-File reached on input operation false
true
false
false
eofbit failbit Logical error on i/o operation false
false
true
false
failbit badbit Read/writing error on i/o operation false
false
true
true
badbit eofbit, failbit and badbit are member constants with implementation-defined values that can be combined (as if with the bitwise OR operator).
1
2
3
4
5
6
7
8
9
10
11
// getting the state of stream objects
#include <iostream> // std::cerr
#include <fstream> // std::ifstream
int main () {
std::ifstream is;
is.open ("test.txt");
if ( (is.rdstate() & std::ifstream::failbit ) != 0 )
std::cerr << "Error opening 'test.txt'\n";
return 0;
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4