如何做INT main()和无效的主要()工作 [英] how does int main() and void main() work
问题描述
我是C语言的初学者。任何人都可以在使用详细示例如何main()中,诠释的main(),无效的主要(),主要(无效),无效的主要(无效),INT主要(无效)用C语言文字工作解释一下吗?由于在什么是happeneing当我们用void main()和正在发生的事情时,我将int main()的简单的语言等。结果
我知道,但无法理解它是什么做的:
I am a beginner in C language. Can anyone explain in detail using example how main(),int main(), void main(), main(void), void main(void), int main(void) work in C language? As in what is happeneing when we use void main() and what is happening when i use int main() in simple language and so on.
I know but cant understand what is it doing:
- 的main() - 函数没有参数
- INT的main() - 函数返回int值
- 无效的主要() - 函数返回什么等等
当我使用INT的main()返回0它仍然给我的输出时,采用同样的作为写简单的Hello World无效的主要()),所以它是如何工作的?什么是它的应用程序?
when i write simple hello world using the int main() return 0 it still gives me the same output as when using void main()) so how does it work? What is its application?
推荐答案
无论是的main()
或无效的主要()
是标准C.前者是允许的,因为它有一个隐含的 INT
的返回值,使其成为同 INT的main()
。 主
的返回值的目的是为了返回退出状态到操作系统。
Neither main()
or void main()
are standard C. The former is allowed as it has an implicit int
return value, making it the same as int main()
. The purpose of main
's return value is to return an exit status to the operating system.
在标准C,为唯一有效的签名主
是:
In standard C, the only valid signatures for main
are:
int main(void)
和
int main(int argc, char **argv)
您正在使用的格式: INT的main()
是一个古老的样式声明,指出主
需要一个不明数量的参数。不要使用它 - 选择高于之一
The form you're using: int main()
is an old style declaration that indicates main
takes an unspecified number of arguments. Don't use it - choose one of those above.
这篇关于如何做INT main()和无效的主要()工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!