Objective-c main routine, what is: int argc, const char * argv[]

后端 未结 6 1366
长情又很酷
长情又很酷 2021-02-05 07:40

What are the arguments passed into the main method of a command-line program:

int main(int argc, const char * argv[])

what is the first int mea

6条回答
  •  无人共我
    2021-02-05 08:36

    As wikipedia (and any other source says):

    int main(void)

    int main(int argc, char *argv[])

    The parameters argc, argument count, and argv, argument vector, respectively give the number and value of the program's command-line arguments. The names of argc and argv may be any valid identifier in C, but it is common convention to use these names. In C++, the names are to be taken literally, and the "void" in the parameter list is to be omitted, if strict conformance is desired. Other platform-dependent formats are also allowed by the C and C++ standards, except that in C++ the return type must stay int; for example, Unix (though not POSIX.1) and Microsoft Windows have a third argument giving the program's environment, otherwise accessible through getenv in stdlib.h:

    int main(int argc, char **argv, char **envp)

提交回复
热议问题