_except
-
Why don't execution function MessageBox(L"DIVIDE BY ZERO"); ? The code is skipping. #include "Excpt.h" #include "Winnt.h" #include "cmath" float fResult; // Bennet, pg.136 //int x,y; float x,y; // x = 5; // y = 0; x = 5.0; y = 0.0; _try // __try { fResult = x/y; } //__except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO) _except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO) { MessageBox(L"DIVIDE BY ZERO"); }
-
Why don't execution function MessageBox(L"DIVIDE BY ZERO"); ? The code is skipping. #include "Excpt.h" #include "Winnt.h" #include "cmath" float fResult; // Bennet, pg.136 //int x,y; float x,y; // x = 5; // y = 0; x = 5.0; y = 0.0; _try // __try { fResult = x/y; } //__except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO) _except (GetExceptionCode() == EXCEPTION_FLT_DIVIDE_BY_ZERO) { MessageBox(L"DIVIDE BY ZERO"); }
You need to turn on floating-point exceptions first... Try #includeing <float.h> and add this bit of code before you do the divide...
_controlfp(0, MCW_EM);
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
modified on Thursday, August 27, 2009 10:48 AM