Created
          July 17, 2015 09:26 
        
      - 
      
- 
        Save krysseltillada/64bb40efdaac2d68c93a to your computer and use it in GitHub Desktop. 
     i/o condition states ( ios::badbit, goodbit, eofbit, failbit && std::cin.bad(), good(), eof(), fail() )
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #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; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment