您的位置:首页 > 大数据 > 人工智能

argc argv -主函数main的参数 2011.06.08

2011-06-08 15:11 337 查看
#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()的
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: