C++ main参数

c++main函数传递的参数解析。
int main(int argCount,char * argValue[]){
    printf("Arg count: %d\n",argCount);
    if (argCount > 1){
        for (int i=0;i<argCount;i++){
            printf("%s\n",argValue[i]);
        }
    }
    return 0;
}
lgh@822:~/workspace_t/LC/Debug> ./LC -f 1 -d 2
Arg count: 5
./LC   # 运行的程序名称
-f     # 第一个参数
1     # 第二个参数
-d     # 第三个参数
2     # 第四个参数

猜你喜欢

转载自blog.csdn.net/yidu_fanchen/article/details/80486187