The main function of C language usually contains argc and argv, which are written as follows:
int main(int argc,char *argv[])
int main(int argc,char **argv)
These two parameters are explained in detail as follows:
argc : Total number of arguments passed in from the command line
argv : *argv[] is an array of pointers, in which the stored pointers point to all command line parameters, argv [0] points to the global path of the program, argv [1] points to the first string after executing the program name in the DOS command line, and argv [2] points to the second string.
给main()函数传递两个参数,int argc和char∗argv[]
argc:表示命令行参数的个数,不许要用户传递,它会根据用户从命令行输入的参数个数,自动确定
argv[]:存储用户从命令行传递进来的参数,它的第一个成员是用户运行的程序名字,也可写为char∗∗argv
Question 3:
Explanation: All the options mentioned (./a.out, ./test, ./fun.out.out) are simply the command without any argument. A command is always stored as argument vector zero i.e., argv[0] always contain the command where as argv[1], argv[2], etc. contains the arguments to the commands, if any.