fork download
#include 
using namespace std;

int main ()
{
    cin.exceptions(ios::failbit);
    int foo;
    try
    {
        cin >> foo;
    }
    catch (const exception& e)
    {
        cerr << "Exception occured." << e.what() << '\n';
        return 0;
    }
    cout << "Should not output this";
}  
Success #stdin #stdout 0.01s 2812KB
stdin
test
stdout

Standard output is empty