- C language
- Basic grammar
- here
main function
The C language program is executed from the main function.
int main (void) { }
The return type of the main function is a type compatible with int type or int type in the C language specification, but it should be obediently int type. It's a good idea to keep it.
If you don't receive command line arguments, it's a good idea to leave them as " void type" which means there are no arguments.
If the main function omits returning the return value, the compiler automatically adds "return 0;" at the end.
int main (void) { } // Same meaning as below int main (void) { return 0; }
Command line arguments
The main function can accept command line arguments.
int main (int argc, char * argv []) { }
The command line arguments are described in detail below.