- 论坛徽章:
- 0
|
本帖最后由 SNYH 于 2012-03-13 23:09 编辑
关于void main.
我记得的是
1 无宿主环境下是理所当然的可以使用void main (main根本不会结束怎么会使用返回值)
2 宿主环境下必须使用int man的两种形式。
但刚特意查看了C99标准文档
5.1.2.2.1 Program startup
1 The function called at program startup is named main. The implementation declares no
prototype for this function. It shall be defined with a return type of int and with no
parameters:
int main(void) { /* ... */ }
or with two parameters (referred to here as argc and argv, though any names may be
used, as they are local to the function in which they are declared):
int main(int argc, char *argv[]) { /* ... */ }
or equivalent;
9)
or in some other implementation-defined manner
发现自己认识的也是不准确的,
所以在引用标准的时候最好还是顺手查看一下。
但这一条还是应该说明为什么void main不对(因为我们大多时候是在操作系统下编程) |
|