Share via


basic_ios::setstate

Sets additional flags.

void setstate( 
   iostate _State 
);

Parameters

  • _State
    Additional flags to set.

Remarks

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

Example

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

int main( ) 
{
   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
   return 0;
}
0
1

Requirements

Header: <ios>

Namespace: std

See Also

Reference

basic_ios Class

iostream Programming

iostreams Conventions