Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. #include <iostream> /// std::cout; std::endl;
  2.  
  3. int main ()
  4. {
  5.  
  6. int i = 0;
  7.  
  8. std::cin >> i; /// inserting some data into the stream and returns a state return by input operator(insertion operetor)
  9.  
  10. if (std::cin.rdstate() == std::cin.badbit) /// checks the following conditions
  11. std::cout << "bad bit " << std::endl;
  12. else if (std::cin.rdstate() == std::cin.goodbit)
  13. std::cout << "good bit " << std::endl;
  14. else if (std::cin.rdstate() == std::cin.eofbit)
  15. std::cout << "eof bit " << std::endl;
  16. else if (std::cin.rdstate() == std::cin.failbit) { /// if the condition of the stream is not that fatal then bypassing it
  17. std::cout << "fail bit bypassing the stream" << std::endl;
  18. std::cin.clear ();
  19. if (std::cin.rdstate() == std::cin.goodbit)
  20. std::cout << "good bit" << std::endl;
  21. else
  22. std::cout << "Bad bit " << std::endl;
  23. } else {
  24. std::cout << "no input" << std::endl;
  25. }
  26.  
  27. return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement