C++ - char** argv vs. char* argv[]

后端 未结 7 1187
别跟我提以往
别跟我提以往 2020-12-12 12:09

What is the difference between char** argv and char* argv[]? in int main(int argc, char** argv) and int main(int argc, char* arg

7条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 12:57

    For the first part of the question:

    • char** argv: pointer to a pointer to a char
    • char* argv[]: pointer to an array

    So the question is whether a pointer to a type C and an array C[] are the same things. They are not at all in general, BUT they are equivalent when used in signatures.

    In other words, there is no difference in your example, but it is important to keep in mind the difference between pointer and array otherwise.

提交回复
热议问题