版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tianxieeryang/article/details/83989313
argc、argv用命令行编译时有用
argc:整数
srgv:二维数组、指针的指针、指针数组
例子
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char** argv) {
int i, n;
printf("There are %d arguments:\n", argc - 1);
for (i = 1; i < argc; i++)
printf("%d : %s\n", i, *(argv + i));
return 0;
}
编译:gcc test_main.c -o test_main
运行:./test_main I "love" "you"
结果: