fork(1) download
  1. #include <iostream>
  2.  
  3. int main() {
  4. std::istream &fin = std::cin;
  5. fin.get(); // 1st byte extracted
  6. fin.get(); // try to extract 2nd byte
  7. std::cout << fin.eof() << fin.good() << '\n'; // eof is triggered
  8. fin.clear();
  9. std::cout << fin.eof() << fin.good() << '\n'; // eof is triggered
  10. fin.unget(); // return back
  11. std::cout << fin.eof() << fin.good() << '\n'; // eof is now reset
  12. }
Success #stdin #stdout 0s 3344KB
stdin
x
stdout
10
01
00