fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. bool prompt(std::string &str)
  5. {
  6. cout << "> ";
  7. if (cin) cout << endl << "Everything is ok" << endl;
  8. std::getline(std::cin, str);
  9. if (!cin) cout << "cin is failed" << endl;
  10. return true;
  11. }
  12. int main()
  13. {
  14. std::string obj;
  15. std::cin.setstate(std::ios::eofbit);
  16. prompt(obj);
  17. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
> 
Everything is ok
cin is failed