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()的
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()的
相关文章推荐
- main()函数的参数作用介绍(转载)!
- 带参数的main()函数
- main()函数的参数:本程序的详细路径(包括完整的文件名)
- main 函数的两个参数
- 基础备忘:带参数的main 函数
- main()函数的参数 int main(int argc, char* argv[])
- main()函数输入参数的含义与介绍
- c语言中 main()函数的参数说明
- main 函数中的 argc argv[ ]的意义
- main()函数的参数
- main(int argc, char*argv[])函数里参数的含义
- main()函数的两个参数
- void声明空参数表,main()函数的参数也可以用void填充表示没有参数
- 带参数的main()函数
- main()函数的输入参数 main(int argc, char** argv)
- main 函数参数中 argc/argv的相关讨论和使用
- C++学习笔记 - main()函数及其参数
- [C]main 函数的参数
- error C2470: “main()”: 看起来像函数定义,但没有参数列表;跳过明显的函数体
- 【C】关于main()函数参数的问题;