From C11:
If the return type of the main function is a type compatible with
int, a return from the initial call to the main function is equivalent
to calling the exit function with the value returned by the main
function as its argument; reaching the } that terminates the main
function returns a value of 0. If the return type is not compatible
with int, the termination status returned to the host environment is
unspecified.
After the call to printf
; control reaches the closing brace }
, terminates main
, and thus returns to the host environment with an exit status of EXIT_SUCCESS
, or 0
.
Also note that it states:
The function called at program startup is named main. The
implementation declares no prototype for this function. It shall be
defined with a return type of int and with no parameters:
int main (void) { /* ... */ }
or with two parameters (referred to here as argc and argv, though any names may be used, as they are
local to the function in which they are declared):
int main (int argc, char *argv[]) { /* ... */ }
or equivalent; or in some other implementation-defined manner.