c++ - What does it mean by setting the failbit/badbit/eofbit? -
what mean "setting failbit" - can infer underlying code failbit set (it non-zero) before when error occurs - on passing input t value of failbit still remains same - why remains same before
` #include <iostream> using namespace std; int main() { int i; if(cin.good()) { cout<<"all good"<<endl; cout<<"rdstate: "<<cin.rdstate()<<" failbit: ". <<cin.failbit<<endl; } cin>>i; while(cin.fail()) { cout<<"failed"<<endl; cout<<"rdstate: "<<cin.rdstate()<<" failbit: ". <<cin.failbit<<endl; break; } return 0; }
Comments
Post a Comment