我可以省略主要用C回报? [英] Can I omit return from main in C?
问题描述
在C ++中,3.6.1主要功能
(3.6.1 / 5)主要return语句有离开的主要功能(破坏具有自动存储时间的对象)的影响,
调用的返回值作为参数退出。 如果控制到达
主而不会遇到return语句结束时,效果是
该执行返回0;
块引用>我可以做如下的C99不返回0?
INT的main(){}
解决方案是的,作为C99的,达到了
}
在主返回0结束时,如果返回类型的主
是兼容INT
。
5.1.2.2.3计划终止
如果在
主
函数的返回类型为int类型兼容,从最初的调用的返回的主
功能相当于调用退出
由主
函数作为参数返回的值函数; < SUP> 11)达到}
终止的主
函数返回值为0。如果返回类型是不符合INT
兼容,终止状态返回到主机环境是不确定的。
块引用>In C++, 3.6.1 Main function
(3.6.1/5) A return statement in main has the effect of leaving the main function (destroying any objects with automatic storage duration) and calling exit with the return value as the argument. If control reaches the end of main without encountering a return statement, the effect is that of executing return 0;
Can I do the following in C99 without return 0?
int main() { }
解决方案Yes, as of C99, reaching the
}
at the end of main returns 0 if the return type ofmain
is compatible withint
.5.1.2.2.3 Program termination
If the return type of the
main
function is a type compatible with int, a return from the initial call to themain
function is equivalent to calling theexit
function with the value returned by themain
function as its argument;11) reaching the}
that terminates themain
function returns a value of 0. If the return type is not compatible withint
, the termination status returned to the host environment is unspecified.
这篇关于我可以省略主要用C回报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!