Export (0) Print
Expand All

basic_ios::setstate

Sets additional flags.

void setstate( 
   iostate _State 
);

_State

Additional flags to set.

The member function effectively calls clear(_State | rdstate).

// basic_ios_setstate.cpp
// compile with: /EHsc
#include <ios>
#include <iostream>

int main( ) 
{
   using namespace std;
   bool b = cout.bad( );
   cout << b << endl;   // Good
   cout.clear( ios::badbit );
   b = cout.bad( );
   // cout.clear( );
   cout << b << endl;   // Is bad, good
   b = cout.fail( );
   cout << b << endl;   // Not failed
   cout.setstate( ios::failbit );
   b = cout.fail( );
   cout.clear( );
   cout << b << endl;   // Is failed, good
}
0 1

Header: <ios>

Namespace: std

Community Additions

ADD
Show:
© 2014 Microsoft