by admin » Wed Jan 27, 2010 2:25 pm
Catching stack overflow
#include <iostream>
#include <windows.h>
using namespace std;
int F(int a)
{
return F(a);
}
void main()
{
__try
{
// Recursive call
F(10);
}
__except(GetExceptionCode() == EXCEPTION_STACK_OVERFLOW? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{
cout<<"stack overflow error"<<endl;
}
}