What does int argc, char *argv[] mean?

前端 未结 8 2124
萌比男神i
萌比男神i 2020-11-21 05:18

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

8条回答
  •  一向
    一向 (楼主)
    2020-11-21 05:52

    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.

提交回复
热议问题