Main function
From cppreference.com
A program shall contain a global namespace function named main, which is the designated start of the program in hosted environment. It shall have one of the following forms:
int main() { body }
|
(1) | ||||||||
int main( int argc, char* argv[] ) { body }
|
(2) | ||||||||
int main( /* implementation-defined */) { body }
|
(3) | ||||||||
1) A
main
function running independently of environment-provided arguments.2) A
main
function accepting environment-provided arguments. The names of argc and argv are arbitrary, as well as the representation of the types of the parameters: int main(int ac, char** av) is equally valid.
3) A
main
function of implement-defined type, returning int. The C++ standard recommends implementation-defined
main
functions to place the extra (optional) parameters after argv.argc | - | Non-negative value representing the number of arguments passed to the program from the environment in which the program is run. |
argv | - | Pointer to the first element of an array of argc + 1 pointers, of which the last one is null and the previous ones, if any, point to null-terminated multibyte strings that represent the arguments passed to the program from the execution environment. If argv[0] is not a null pointer (or, equivalently, if argc > 0), it points to a string that represents the name used to invoke the program, or to an empty string. |
body | - | The body of the main function.
|
Contents |