在C主程序(无效)之间的区别和主要() [英] Difference between main(void) and main() in C

查看:132
本文介绍了在C主程序(无效)之间的区别和主要()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能告诉我之间的差异主要INT() INT主要(无效)?为什么他们都工作,什么是默认的参数 INT的main()

Can anyone tell me the difference between int main() and int main(void)? Why do both of them work and what is the default argument to int main()?

推荐答案

在通常情况下没有区别。这绝不是'默认参数的main()',因为它没有参数的。

No difference under ordinary circumstances. This is no 'default argument to main()', since it has no arguments at all.

这里的非普通情况。如果你写自己的呼吁为主,那么()将允许你通过它,你喜欢的任何参数,而(无效)将迫使你通过它没有。不过,这一切都不重要了99.99999999%的情况下,这是主要的运行时被调用来启动程序的条款。运行时不知道也不关心,如果你写()(无效)

Here's the un-ordinary circumstance. If you write your own call to main, then () will permit you to pass it any parameters you like, while (void) will force you to pass it none. Still, none of this matters in terms of the 99.99999999% case, which is main being invoked by the runtime to launch your program. The runtime neither knows nor cares if you write () or (void).

如果您code标准的 INT主(INT ARGC,字符** argv的)你会在那里得到你的命令行参数。

If you code the standard int main(int argc, char **argv) you will get your command-line parameters in there.

这篇关于在C主程序(无效)之间的区别和主要()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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