#include <iostream>
#include <exception>
using namespace std;
void
unexpectedHandler ()
{
cout << "Unexpected!" << endl;
}
void
terminateHandler ()
{
cout << "Terminate!" << endl;
}
int
main (int argv, char *argc[])
{
int a;
int b;
try
{
if (argv < 3)
throw exception ();
a = atoi (argc[1]);
b = atoi (argc[2]);
}
catch (exception e)
{
a = 2;
b = 0;
}
set_unexpected (unexpectedHandler);
set_terminate (terminateHandler);
try
{
cout << a / b << endl;
}
catch (...)
{
cout << "Shit happens!" << endl;
}
return 0;
}