如何做INT main()和无效的主要()工作 [英] how does int main() and void main() work

查看:191
本文介绍了如何做INT main()和无效的主要()工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是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:


  1. 的main() - 函数没有参数

  2. INT的main() - 函数返回int值

  3. 无效的主要() - 函数返回什么等等

当我使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆