关于main函数的参数
来源:互联网 发布:淘宝网春英服饰 编辑:程序博客网 时间:2024/05/22 19:40
我晕了。以前一直以为main函数只有两个入口参数:参数个数和参数字符串列表。今天才发现它居然还有第三个参数:环境变量。
说明如下:
对于main函数而言,一般情况下有如下的特性。
The main function marks the beginning and end of program execution. A C or C++ program must have one function named main.
main的原型可以是main( int argc, char *argv[ ], char *envp[ ] )
那些参数都是系统传递给它的,而且不一定要真正使用所有的这些参数。
它可以接受入口参数说明:
argc
An integer specifying how many arguments are passed to the program from the command line. Because the program name is considered an argument, argc is at least 1.
argv
An array of null-terminated strings. It can be declared as an array of pointers to char (char *argv[ ] ) or as a pointer to pointers to char (char **argv ). The first string (argv[0]) is the program name, and each following string is an argument passed to the program from the command line. The last pointer (argv[argc]) is NULL.
envp
A pointer to an array of environment strings. It can be declared as an array of pointers to char (char *envp[ ]) or as a pointer to pointers to char (char **envp). The end of the array is indicated by a NULL pointer. The environment block passed to main is a “frozen” copy of the current environment. If you subsequently change the environment via a call to putenv , the current environment (as returned by getenvand the _environvariable) will change, but the block pointed to by envp will not change. This argument is ANSI compatible in C, but not in C++.
我没有研究过C99标准,也很少在非WINDOWS环境下编程。我不知道第三个参数是标准中的参数,还是VC编译器中独有的参数。
- 关于main函数的参数
- 关于main函数的参数
- 关于main函数的参数
- 关于main函数:指针数组作为main函数的参数
- 关于Main函数参数的复习
- 关于Main函数的命令行参数
- 关于带参数的main函数
- 关于main函数的三个参数
- 关于main函数的三个参数
- 关于main函数的参数argc,argv
- 关于main()函数参数的问题
- 关于main函数的第二个参数
- main函数的参数
- main函数的参数
- Main 函数的参数
- main()函数的参数
- main函数的参数
- main函数的参数
- 240多个jQuey插件
- (PS)かまいたちの夜•特別篇 汉化笔记 七
- CString操作指南---转帖于VC知识库文章
- 校外实训周报(八)
- linux下编写c程序手顺
- 关于main函数的参数
- html关键字
- 算法学习(六)--优先队列
- (PS)かまいたちの夜•特別篇 汉化笔记 八
- Fedora 12 13 14基础环境配置
- 正在读2:测试驱动的面向对象开发
- Linux设备驱动开发学习笔录-(init函数和exit函数的书写)
- VISTA WIN7下如何以管理员身份打开程序
- 如何提高Brew开发的效率