fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main ()
  5. {
  6. cin.exceptions(ios::failbit);
  7. int foo;
  8. try
  9. {
  10. cin >> foo;
  11. }
  12. catch (const exception& e)
  13. {
  14. cerr << "Exception occured." << e.what() << '\n';
  15. return 0;
  16. }
  17. cout << "Should not output this";
  18. }
Success #stdin #stdout 0.01s 2812KB
stdin
test
stdout
Standard output is empty