int main()? [英] int main()?

查看:91
本文介绍了int main()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




这是我的第一篇Usenet帖子,请原谅我,请指出我犯的任何

错误。


不确定Thunderbird是否是一个好消息读者。


我刚刚开始学习C,来自一年的背景
Pascal和Delphi的



查看代码示例并完成K& R第二版,

我很困惑为什么有时候人们会用:


int main()

{


}


在书中,他们只使用:


main()

{


}


提前感谢


-

回收你的收件箱! http://www.mozilla.org/products/thunderbird

推荐答案

Jonathan Pritchard写道:
Jonathan Pritchard wrote:




这是我的第一篇Usenet帖子,请原谅我,请指出我犯的任何

错误。
Hi,

This is my first Usenet post so forgive me, and please point out any
mistakes I make.



你可以肯定会有人;-)

说真的,非常欢迎那些想做正确事情的人。给予

想要学习并且想要正确行事的态度

无知和错误将很快被原谅和遗忘。

You can be sure that people will ;-)
Seriously, people who want to do the right thing are very welcome. Given
the attitude of wanting to learn and wanting to behave "correctly"
ignorance and mistakes will be quickly forgiven and forgotten.


不确定Thunderbird是否是一个好消息读者。
Not sure if Thunderbird is a good news reader.



这是我使用的所以你可以猜测我的意见。

It''s what I use so you can guess my opinion.


我已经刚开始学习C,来自Pascal和Delphi的一年背景




查看代码示例并完成K& R Second版本,
I''ve just been starting to learn C, coming from a background of a year
in Pascal and Delphi.

Looking through code examples and working through K&R Second Edition,



一本优秀的书虽然不完美。您应该查看
勘误表=_ blank> http://cm.bell-labs.com/cm/cs/cbook/2ediffs.html


我是困惑为什么有时人们会使用:


int main()

{


}


然而在书中,他们只是使用:


main()

{


}
I''m confused as to why sometimes people use:

int main()
{

}

Whereas in the book, they just use:

main()
{

}



很多人,特别是在这里,预感

int main(无效)

{

}


有几个原因。

明确是一件好事并指定一个void参数

list强制编译器在你尝试递归调用main

传递参数时抱怨。


隐式int(即编译器假设一个int类型,如果没有指定

)已从最新删除C标准制作main()

无效。不幸的是,最新的C标准并不常见,但是如果没有显着的收益,那么与它不相容仍然没有意义。

。 />
-

Flash Gordon

Many people, especially around here, preffer
int main(void)
{
}

There are a couple of reasons.

Being explicit is generally a good thing and specifying a void parameter
list forces the compiler to complain if you try to recursively call main
passing parameters.

Implicit int (i.e. the compiler assuming a type of int if nothing was
specified) has been dropped from the latest C standard making "main()"
invalid. The latest C standard is, unfortunately, not commonly
implemented but there is still no point in being incompatible with it
when there is not significant benefit to be gained.
--
Flash Gordon


Jonathan Pritchard< jo ********** @ f2s .comwrote:
Jonathan Pritchard <jo**********@f2s.comwrote:

这是我的第一篇Usenet帖子,请原谅我,请指出我犯的任何

错误。
This is my first Usenet post so forgive me, and please point out any
mistakes I make.



你做得比大多数好多了:-)

You''ve done a lot better than most :-)


不确定Thunderbird是不是一个好消息的读者。
Not sure if Thunderbird is a good news reader.



它的工作原理,无论如何都是比谷歌破损的
界面或LookOutExpress更好的选择。

It works, and in any case is a much better choice than Google''s broken
interface or LookOutExpress.


查看代码示例并完成K& R第二版,

我很困惑为什么有时人们会使用:
Looking through code examples and working through K&R Second Edition,
I''m confused as to why sometimes people use:



(这与你的问题没有直接关系,但是你可以在
href =http://c-faq.comtarget =_ blank> http://c-faq.com
,你可能会发现11.12a

兴趣 - http://c-faq.com/ansi/maindecl.html 。)

(This isn''t directly relevant to your question, but you would do very
well to read the C FAQ at http://c-faq.com, and you might find 11.12a
to be of interest - http://c-faq.com/ansi/maindecl.html.)


int main()
int main()



Flash讨论了这个和

int main(无效)


虽然我不相信他提到了

Flash discussed the difference between this and

int main(void)

although I don''t believe he mentioned that


main()
main()



在C89标准下有效(允许隐式int),但不是

下C99标准(没有)。


-

C. Benson Manica |我*应该*知道我在说什么 - 如果我

cbmanica(at)gmail.com |不,我需要知道。火焰欢迎。

is valid under the C89 standard (which allowed implicit int), but not
under the C99 standard (which does not).

--
C. Benson Manica | I *should* know what I''m talking about - if I
cbmanica(at)gmail.com | don''t, I need to know. Flames welcome.


Christopher Benson-Manica写道:
Christopher Benson-Manica wrote:

Jonathan Pritchard< jo ***** *****@f2s.comwrote:
Jonathan Pritchard <jo**********@f2s.comwrote:

这是我的第一篇Usenet帖子,请原谅我,请指出任何

错误我做。
This is my first Usenet post so forgive me, and please point out any
mistakes I make.



你做得比大多数好多了:-)


You''ve done a lot better than most :-)


不确定Thunderbird是不是一个好消息的读者。
Not sure if Thunderbird is a good news reader.



它有效,而且无论如何都是比Google破坏的
界面或LookOutExpress更好的选择。


It works, and in any case is a much better choice than Google''s broken
interface or LookOutExpress.



Google的界面以什么方式破坏?

In what way is Google''s interface broken ?


这篇关于int main()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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