exit terminates normal program execution and returns a status to the runtime system. Calling exit(s) has the same termination effect as returning s from main; exit never returns to its caller. section 7.2
Terminate after an unrecoverable output failure
if (puts("hello world") == EOF) { perror("can't output to terminal:"); exit(EXIT_FAILURE); } Check the library function's return value, report the failure, and terminate with EXIT_FAILURE. section 8.1.3
Use exit according to the control-flow situation:
- Prefer return from main for ordinary program termination. section 8.8
- Use exit inside a function that must terminate normal control flow rather than return through its callers. section 8.8
- Pass EXIT_SUCCESS or EXIT_FAILURE when portable success and failure status values are sufficient. section 7.2
- Allow normal cleanup to run; avoid more abrupt termination functions unless inhibiting library cleanup is necessary. section 8.8
[[noreturn]] void exit(int status);
Displays the nonreturning function prototype for exit. section 7.2

