#include <stdio.h>
int main(int argc, char * argv[])
{
printf("the number: %d/n", argc);
for (int i=0; i<argc; i++)
{
printf("the %d commond is %s/n", i, argv[i]);
}
return 0;
}
文件名为test,编译生成test.exe
dos下执行:
test 1 2 3 4 5
输出:
the number: 6
the 0 commond is argc
the 1 commond is 1
the 2 commond is 2
the 3 commond is 3
the 4 commond is 4
the 5 commond is 5
总结:
参数argc是子串的个数,
参数argv是指针数组。
这是系统传给主函数main()的