It is known how to catch the float division-by-zero exception with the usage of
signal(SIGFPE, handler)
but it doesn\'t catch integer divis
Division by zero leads to undefined behavior, there is no C language construct that can do anything about it. Your best bet is to not divide by zero in the first place, by checking the denominator.
If you want to "catch" (note, C has no exceptions) this error, it will be dependent on your compiler and OS, which you haven't listed. By the way, _control87
has only to do with floating-point operations, and nothing to do with integer operations.
Check what you are dividing against...?
// if below = 0 then do not divide, just put answer as zero
if (below == 0) {
result = 0;
} else {
result = above/below;
}