65,204
社区成员
发帖
与我相关
我的任务
分享int main()
{
cin.setstate(istream::badbit);
cout << (cin.rdstate() & istream::failbit) << endl;
if (cin.fail())
cout << "fail" << endl;
else
cout << "not fail" << endl;
}

basic_ios::fail
Indicates the status of rdstate & failbit.
bool fail( ) const;
Return Value
1 or true if rdstate & failbit is nonzero, otherwise 0 or false.