什么是main()的返回? [英] What does main() return?
问题描述
可能重复:结果
什么都要用C的main()的返回/ C ++?
块引用>什么价值这个函数返回。只是普通的主力。
的main()
{
...
}如果函数有两个电源,会发生什么?
解决方案
什么价值这个函数返回。
块引用>
主
必须声明为返回一个INT
。返回值被传递给呼叫者,这通常是在操作系统
称为在程序启动时的功能被命名为主力。实施没有声明
原型此功能。它应带有int和返回类型来定义不
参数:
块引用>INT主要(无效){/ * ... * /}
或具有两个参数(此处称为argc和argv,虽然任何名称可能是
使用,因为它们是局部的,其中声明它们的功能):
块引用>INT主(INT ARGC,CHAR *的argv []){/ * ... * /}
如果函数有两个电源,会发生什么?
块引用>链接器报告错误。
Possible Duplicate:
What should main() return in C/C++?What value does this function return. just plain main.
main() { ... }
and if a function has two mains , what happens?
解决方案What value does this function return.
main
needs to be declared as returning anint
. The return value is passed to the caller, which is usually the operating system.5.1.2.2.1 Program startup
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[]) { /* ... */ }
and if a function has two mains , what happens?
Linker reports an error.
这篇关于什么是main()的返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!