basic_ios::setstate
设置其他标志。
void setstate(
iostate _State
);
参数
- _State
设置的其他标志。
备注
示例
// 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;
}
要求
标头: <ios>
命名空间: std