C90中的main() [英] main() in C90

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

问题描述

在C90中是int main()有效,与int main(void)相同和int

main(int argc,char * argv [])"?

仅C99中的AFAIKint main(void)"和int main(int argc,char * argv [])

- 和** argv语法是唯一有效的。

Hi, in C90 is "int main()" valid, the same as "int main(void)" and "int
main(int argc, char *argv[])"?
AFAIK in C99 only "int main(void)" and "int main(int argc, char *argv[])
- and the **argv syntax" are the only valid ones.

推荐答案

在文章< fm *********** @ ulysses.noc.ntua。 gr>,

Ioannis Vranos< jo ** @ no.spamwrote:
In article <fm***********@ulysses.noc.ntua.gr>,
Ioannis Vranos <jo**@no.spamwrote:

>在C90中是int main ()"有效,与int main(void)相同和int
main(int argc,char * argv [])"?
>Hi, in C90 is "int main()" valid, the same as "int main(void)" and "int
main(int argc, char *argv[])"?


>仅C99中的AFAIKint main(void)"和int main(int argc,char * argv [])
- 和** argv语法是唯一有效的。
>AFAIK in C99 only "int main(void)" and "int main(int argc, char *argv[])
- and the **argv syntax" are the only valid ones.



相关规则在C90和C99之间没有变化。两者都允许

或等价物。


C99仍然允许旧式非原型函数定义:

eg ,


int foo(bar)

int bar;

{...}


仍被接受以及更新


int foo(int bar){...}


使用(void )在函数声明或定义中

表示缺少参数,并通过转换回旧样式,

int main(void)将等效于


int main(/ *这里没有参数* /)

/ *这里没有声明* /


更简单写的int main()

什么是-not-在C99中仍然有效将省略int部分:

函数不再默认为int返回类型如果没有返回类型

是指定的。

-

没有人有权通过
摧毁他人的信仰
要求经验证据。&q UOT; - Ann Landers

The relevant rules did not change between C90 and C99. Both permit
"or equivilents".

C99 still permits the old style non-prototype definition of functions:
e.g.,

int foo(bar)
int bar;
{ ... }

is still accepted as well as the newer

int foo(int bar) { ... }

Using (void) in a function declaration or definition
signals lack of parameters, and by transforming back to the old style,
int main(void) would be equivilent to

int main( /* no parameters here */ )
/* no declarations here */

which is more simply written int main()
What is -not- still valid in C99 would be to leave out the int part:
functions no longer default to int return type if no return type
is specified.
--
"No one has the right to destroy another person''s belief by
demanding empirical evidence." -- Ann Landers


Ioannis Vranos说:
Ioannis Vranos said:

在C90中是int main() "有效,
Hi, in C90 is "int main()" valid,



是的。它在C99中也有效。

Yes. It is also valid in C99.


与int main(void)相同和int

main(int argc,char * argv [])"?
the same as "int main(void)" and "int
main(int argc, char *argv[])"?



是的,这些在C90和C99都有效。

Yes, those are both valid in C90 and in C99.


仅限C99中的AFAIK int main(void)"和int main(int argc,char * argv [])

- 和** argv语法是唯一有效的。
AFAIK in C99 only "int main(void)" and "int main(int argc, char *argv[])
- and the **argv syntax" are the only valid ones.



不,int main()也有效。


此外,任何上述任何完全相同的也是有效。例如:


typedef int cat;

typedef char ** mouse;


cat main(cat run ,鼠标隐藏)

-

Richard Heathfield< http://www.cpax.org.uk>

电子邮件:-http ://万维网。 + rjh @

谷歌用户:< http://www.cpax.org.uk/prg/writings/googly.php>

Usenet是一个奇怪的放置" - dmr 1999年7月29日

No, int main() is also valid.

Also, any exact equivalent of any of the above is also valid. For example:

typedef int cat;
typedef char **mouse;

cat main(cat run, mouse hide)
--
Richard Heathfield <http://www.cpax.org.uk>
Email: -http://www. +rjh@
Google users: <http://www.cpax.org.uk/prg/writings/googly.php>
"Usenet is a strange place" - dmr 29 July 1999


Richard Heathfield< rj*@see.sig.invalidwrites:
Richard Heathfield <rj*@see.sig.invalidwrites:

Ioannis Vranos说:
Ioannis Vranos said:

>在C90中是int main()有效,
>Hi, in C90 is "int main()" valid,



是的。它在C99中也有效。


Yes. It is also valid in C99.


>与int main(void)相同和int
main(int argc,char * argv [])"?
>the same as "int main(void)" and "int
main(int argc, char *argv[])"?



是的,这些在C90和C99都有效。


Yes, those are both valid in C90 and in C99.


>仅限C99中的AFAIK " int main(void)"和int main(int argc,char * argv [])
- 和** argv语法是唯一有效的。
>AFAIK in C99 only "int main(void)" and "int main(int argc, char *argv[])
- and the **argv syntax" are the only valid ones.



不,int main()也有效。


此外,任何上述任何完全相同的也是有效。例如:


typedef int cat;

typedef char ** mouse;


cat main(cat run ,鼠标隐藏)


No, int main() is also valid.

Also, any exact equivalent of any of the above is also valid. For example:

typedef int cat;
typedef char **mouse;

cat main(cat run, mouse hide)



C99中的措辞是这样的,可以说int

main()无效。但是有相当多的证据表明作者

的标准是有效的。请参阅

< http://groups.google.com/group/comp.std.c/browse_thread/thread/fef53cc781d555a4/2d61b64c0ee672e3>

if you're真的很无聊,或者想成为。


在实践中,int main(){/ * ... * /}没问题,但是IMHO

" int main(void){/ * ... * /}"风格更好,因为它更明确。


-

Keith Thompson(The_Other_Keith)< ks * **@mib.org>

诺基亚

我们必须做点什么。这是事情。因此,我们必须这样做。

- Antony Jay和Jonathan Lynn,是部长

The wording in C99 is such that an argument could be made that "int
main()" is not valid. But there''s considerable evidence that authors
of the standard intended it to be valid. See
<http://groups.google.com/group/comp.std.c/browse_thread/thread/fef53cc781d555a4/2d61b64c0ee672e3>
if you''re really bored, or want to be.

In practice, "int main() { /* ... */ }" is ok, but IMHO
"int main(void) { /* ... */ }" is stylistically better because it''s
more explicit.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Nokia
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


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

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