An output failure
A call to puts can fail instead of printing. Check its return value: `if (puts("hello world") == EOF) { perror("can't output to terminal:"); exit(EXIT_FAILURE); }`. The diagnostic makes the failure visible; `exit` ends execution rather than letting the program continue as though output succeeded. section 8.1.3
An exceptional condition can also arise during arithmetic. Integer division or modulo by zero has no mathematical result. Negating `INT_MIN` and certain bit shifts likewise exceed the operations permitted for their operands. Such operations may crash on some platforms; the safe rule is to perform arithmetic only when the result is defined within the underlying type's range. section 15.1.1
Floating-point arithmetic needs a separate check: where infinity is supported, division by zero can produce infinity. `<fenv.h>` names conditions such as `FE_DIVBYZERO`, `FE_INVALID`, and `FE_OVERFLOW`; `feclearexcept` clears indicators before an operation, and `fetestexcept` inspects them afterward. Which macros are available is platform-dependent. section 15.1.1
An exception or other failure does not prescribe one response in C:
- Check library return values and report failures rather than ignoring them. A function may also communicate a specific error through `errno`. section 8.1.3
- When returning an error from a function, preserve required state and release acquired resources. For example, an output failure after `malloc` must not skip `free`. section 15.6
- For a condition that cannot be repaired locally, `longjmp` can transfer control to a target established by `setjmp`; it does not return to the call that invoked it. section 19.5
Figure 19.2 Control flow with setjmp and longjmp: longjmp jumps to the position marked by setjmp.
The control-flow diagram shows the distinction between recognizing a condition where it occurs and resuming at a previously established jump target. section 19.5
























