fork download
  1. #include <cstdio>
  2. #include <iostream>
  3.  
  4. int main() {
  5. using namespace std;
  6.  
  7. char ch;
  8. cin >> ch;
  9.  
  10. cout << boolalpha << "cin.eof(): " << cin.eof() << endl
  11. << "feof(stdin): " << bool(feof(stdin)) << endl;
  12.  
  13. cout << "call cin.clear()..." << endl;
  14. cin.clear();
  15.  
  16. cout << "cin.eof(): " << cin.eof() << endl
  17. << "feof(stdin): " << bool(feof(stdin)) << endl;
  18. }
Success #stdin #stdout 0s 4344KB
stdin
Standard input is empty
stdout
cin.eof(): true
feof(stdin): true
call cin.clear()...
cin.eof(): false
feof(stdin): true