Per the C standard
C99 §5.1.2.2.1 Program startup
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;10 or in some other implementation-defined manner.
10) Thus, int can be replaced by a typedef name defined as int, or the type of argv can be written as char **argv
, and so on.
The closing clause grants implementations their own vices, which is to say, if a program does not follow this, it is no longer standard-compliant and instead reliant on the implementation for compatibility. If you want your main()
to work everywhere, follow one of these and you'll be ok.