argc argv -主函数main的参数 2011.06.08

来源:互联网 发布:linux服务器架设 编辑:程序博客网 时间:2024/06/10 12:29

#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()的

 

原创粉丝点击