...
| Code Block | ||
|---|---|---|
| ||
int main(int argc, char **argv) {
/* ... */
if (/* something really bad happened */) {
return EXIT_FAILURE;
}
/* ... */
return EXIT_SUCCESS;
}
|
| Wiki Markup |
|---|
\[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]\] C99 Section 5.1.2.2.3 has this to say about returning from {{main()}} \[[ISO/IEC 9899-1999|AA. C References#ISO/IEC 9899-1999]\]: |
If the return type of the
mainfunction is a type compatible withint, a return from the initial call to themainfunction is equivalent to calling theexitfunction with the value returned by themainfunction as its argument; reaching the}that terminates themainfunction returns a value of 0. If the return type is not compatible withint, the termination status returned to the host environment is unspecified.
...