Share via


basic_ios::rdstate

 

Reads the state of bits for flags.

Syntax

iostate rdstate( ) const;

Return Value

The stored stream state information.

Example

// basic_ios_rdstate.cpp
// compile with: /EHsc
#include <iostream>
#include <fstream>
using namespace std;

void TestFlags( ios& x ) 
{
   cout << ( x.rdstate( ) & ios::badbit ) << endl;
   cout << ( x.rdstate( ) & ios::failbit ) << endl;
   cout << ( x.rdstate( ) & ios::eofbit ) << endl;
   cout << endl;
}

int main( ) 
{
   fstream x( "c:\test.txt", ios::out );
   x.clear( );
   TestFlags( x );
   x.clear( ios::badbit | ios::failbit | ios::eofbit );
   TestFlags( x );
}
0
0
0

4
2
1

Requirements

Header: <ios>

Namespace: std

See Also

basic_ios Class
iostream Programming
iostreams Conventions