argc,argv解释

    技术2024-07-11  65

    //命名该函数为test.exe #include <stdio.h>//#包含<stdio.h> int main(int argc,char* argv[]) //整数类型主函数(整数类型统计参数个数,字符类型指针数组指向字符串参数) { printf("%d\n",argc); //格式化输出 while(argc) //当(统计参数个数) printf("%s\n",argv[--argc]); //格式化输出 return 0; //返回0;正常退出 }

    argc为参数数量,argv为参数内容 例如运行该函数

    test.exe test hello

    则输出结果为

    3 hello test test.exe

    Processed: 0.012, SQL: 9