In many C++ IDE\'s and compilers, when it generates the main function for you, it looks like this:
int main(int argc, char *argv[])
When I
The main
function can have two parameters, argc
and argv
. argc
is an integer (int
) parameter, and it is the number of arguments passed to the program.
The program name is always the first argument, so there will be at least one argument to a program and the minimum value of argc
will be one. But if a program has itself two arguments the value of argc
will be three.
Parameter argv
points to a string array and is called the argument vector. It is a one dimensional string array of function arguments.