ios::rdstate
iostate rdstate ( ) const;
ios
  cplusplus.com  

Get control state.
  Returns the current stream control state flags.

Parameters.

none
 

Return Value.
  An object of type ios_base::iostate that can contain any combination of the following state flag member constants:

  These are static member constants inherited from ios_base.
  To check for a specific state other than goodbit you should check only if the corresponding bit is set using the & bitwise operator with its specific bitmask, because more than one error state could be set at the same time.

Example.

// getting state of stream object
#include <iostream>
#include <fstream>
using namespace std;

int main () {
  ifstream is;
  is.open ("test.txt");
  if ( (is.rdstate() & ifstream::failbit ) != 0 )
    cerr << "Error opening 'test.txt'\n";
  return 0;
}

Basic template member declaration ( basic_ios<charT,traits> ):
iostate rdstate () const;

See also.
  fail, good, bad, eof, clear,
  ios class


© The C++ Resources Network, 2001