Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. _except

_except

Scheduled Pinned Locked Moved C / C++ / MFC
question
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    durban2
    wrote on last edited by
    #1

    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"); }

    S 1 Reply Last reply
    0
    • D durban2

      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"); }

      S Offline
      S Offline
      Stuart Dootson
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups