I am trying to use the exceptions catching mechanism on a simple piece of C++ code that does on purpose a division by 0:
#include <iostream>
using namespace std;
const int DefaultSize = 10;
int main()
{
int top = 90;
int bottom = 0;
cout << "top / 2 = " << (top/ 2) << endl;
cout << "top / 3 = " << (top/ 3) << endl;
try
{
cout << "top divided by bottom = ";
cout << (top / bottom) << endl;
}
catch(...)
{
cout << "something has gone wrong!" << endl;
}
cout << "Done." << endl;
return 0;
}
The program crashes and doesn't execute the catch block - In Eclipse I am getting a standard error:
0 [main] CPP166 8964 cygwin_exception::open_stackdumpfile: Dumping stack trace to CPP166.exe.stackdump.
Run the program in another IDE NetBeans and have done multiple clen and re-built with no positive results.
Please help I have looked at the related answers but I cannot identify the problem.