siliconwafer wrote:
Hi All,
I am using C on linux and performed a 1/0 operation i.e a divide by
zero using integer variables/constants.it gives me a floating point
exceptionand the program terminates.
I want to access the routine that causes this message to occour and
want to modify it so that my program continues to run.How is exception
handling done in C?Is there a try-catch equivalent?
Interesting that you got a floating-point exception
from an integer calculation ... As far as C is concerned,
attempting to divide by zero produces "undefined behavior,"
meaning that anything at all can happen -- you can get a
floating-point exception, or a bogus answer without any kind
of error indication, or your CPU may overheat and melt into
a puddle of impure glass.
The C language itself makes no promises about what might
happen, but the particular system on which you're running C
might. If so, you'll need to check with people who know the
details of how your system operates; they may be able to tell
you some tricks that go beyond what C itself can deliver.
And no, C has no built-in exception handling, nor any
way to "repair and resume" a failed program. Again, your
system might provide some such capabilities as extensions
to C -- but again, you'll need to ask the system experts,
not the C experts.
--
Er*********@sun.com