A helper can terminate normal execution by calling exit with the status that main would return: _Noreturn void fail(void) { exit(EXIT_FAILURE); } Calling fail does not return to its caller. It terminates the program as though main had evaluated return EXIT_FAILURE. section 7.2
Use exit deliberately when termination must occur outside main:
- Prefer a regular return from main for ordinary program termination. section 8.7
- Call exit from a function that must terminate regular control flow; exit never returns and is treated as equivalent to returning from main. section 7.2 section 8.7
- Pass EXIT_SUCCESS or EXIT_FAILURE when expressing success or failure portably. section 7.2
- Allow normal termination processing to perform runtime cleanup, including flushing or closing files and releasing resources. section 8.7
- Reserve other terminating functions for cases that specifically require suppressing library cleanup. section 8.7
_Noreturn void exit(int status);
!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":14}],[{\"line\":0,\"ch\":15},{\"line\":0,\"ch\":19}],[{\"line\":0,\"ch\":20},{\"line\":0,\"ch\":23}]]"}
!@%STYLE%@!
Inspect the declaration showing that exit accepts an int status, returns void, and is marked _Noreturn. section 7.2

