Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream> /// std::cout; std::endl;
- int main ()
- {
- int i = 0;
- std::cin >> i; /// inserting some data into the stream and returns a state return by input operator(insertion operetor)
- if (std::cin.rdstate() == std::cin.badbit) /// checks the following conditions
- std::cout << "bad bit " << std::endl;
- else if (std::cin.rdstate() == std::cin.goodbit)
- std::cout << "good bit " << std::endl;
- else if (std::cin.rdstate() == std::cin.eofbit)
- std::cout << "eof bit " << std::endl;
- else if (std::cin.rdstate() == std::cin.failbit) { /// if the condition of the stream is not that fatal then bypassing it
- std::cout << "fail bit bypassing the stream" << std::endl;
- std::cin.clear ();
- if (std::cin.rdstate() == std::cin.goodbit)
- std::cout << "good bit" << std::endl;
- else
- std::cout << "Bad bit " << std::endl;
- } else {
- std::cout << "no input" << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement