argc and argv in the Main function

argc is the abbreviation of argument count, which indicates the number of parameters passed into the main function;

argv is the abbreviation of argument vector, which represents the parameter sequence or pointer passed to the main function, and the first parameter argv[0] must be the name of the program and contains the full path where the program is located, so argc is at least 1 (file name). itself is also a parameter), to be precise, the number of parameters of the main function that we need to input should be argc-1;

#include <stdio.h>  
int main(int argc,char *argv[]){  
    int a=0,b=0;  
    printf("argc:%d\n",argc);  
    printf("argv[0]:%s\n",argv[0]);  
    printf("argv[1]:%s\n",argv[1]);  
    printf("argv[2]:%s\n",argv[2]);  
    return 0;  
}  

Examples are as follows
write picture description here

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325918827&siteId=291194637