...
Since main()
is defined to have return type int
, another valid exit strategy is to simply use a return
statement.
Code Block | ||
---|---|---|
| ||
int main(int argc, char **argv) {
/* ... */
return status;
}
|
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()}}: |
...
The quickest and most abrupt way to terminate a program, abort()
takes no arguments, and always signifies abnormal termination to the operating system.
Code Block | ||
---|---|---|
| ||
{code:bgColor=#ccccff}
#include <stdlib.h>
/* ... */
if (/* something really bad happened */) {
abort();
}
|
...