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

前端 未结 8 2123
萌比男神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.

    0 讨论(0)
  • 2020-11-21 05:56

    The first parameter is the number of arguments provided and the second parameter is a list of strings representing those arguments.

    0 讨论(0)
提交回复
热议问题