主要回报值stange问​​题 [英] main return value stange question

查看:79
本文介绍了主要回报值stange问​​题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,所有成员,


i在C中有一个奇怪的问题。

main()

{

printf("%d",main);

}


这里o / p对于TC ++版本中的所有m / c都相同3.0即657.

我认为这不是垃圾。

您的想法??

PLZ回复。

hello to all members,

i have strange question in C.
main()
{
printf("%d",main) ;
}

here o/p is same for all m/c in TC++ version 3.0 i.e 657.
I think this is not garbage.
what u think??
plz reply.

推荐答案



" Sweety" < SW ************ @ yahoo.co.in>在消息中写道

news:11 ************************** @ posting.google.c om ...

"Sweety" <sw************@yahoo.co.in> wrote in message
news:11**************************@posting.google.c om...
你好,所有成员,
我在C中有一个奇怪的问题。
main()
{
printf("%d" ;,主要);
}
这里o / p对于TC ++ 3.0版本中的所有m / c都是相同的,即657.
我认为这不是垃圾。
你的想法??
hello to all members,

i have strange question in C.
main()
{
printf("%d",main) ;
}

here o/p is same for all m/c in TC++ version 3.0 i.e 657.
I think this is not garbage.
what u think??




上述程序的行为未定义。


-Mike



The behavior of the above program is undefined.

-Mike


自称为Sweety的东西写道:
Something that calls itself Sweety wrote:
你好,所有成员,
我在C中有一个奇怪的问题。 br /> main()
{
printf("%d",main);
}
这里o / p对所有m / c都相同在TC ++ 3.0版本即657.
我认为这不是垃圾。
你觉得怎么样?


我认为你是一个可爱的小巨魔。

plz回复。
cat Sweety.c
#include< stdio.h>


main(){

printf("%d" ;,主要);

}

gcc -Wall -std = c99 -pedantic -o Sweety Sweety.c
hello to all members,

i have strange question in C.
main()
{
printf("%d",main) ;
}

here o/p is same for all m/c in TC++ version 3.0 i.e 657.
I think this is not garbage.
what u think??
I think you be a sweet little troll.
plz reply. cat Sweety.c #include <stdio.h>

main() {
printf("%d", main);
}
gcc -Wall -std=c99 -pedantic -o Sweety Sweety.c



Sweety .c:3:警告:返回类型默认为int'

Sweety.c:在函数main中:

Sweety.c:4:警告: int格式,指针arg(arg 2)


Sweety.c:3: warning: return type defaults to `int''
Sweety.c: In function `main'':
Sweety.c:4: warning: int format, pointer arg (arg 2)


Sweety写道:

你好,所有成员,

我在C中有一个奇怪的问题。
main()
{/> printf("%d",main);
}
<这里o / p对于TC ++ 3.0版本中的所有m / c都是相同的,即657.
我认为这不是垃圾。
你觉得怎么样?

hello to all members,

i have strange question in C.
main()
{
printf("%d",main) ;
}

here o/p is same for all m/c in TC++ version 3.0 i.e 657.
I think this is not garbage.
what u think??




这是垃圾。更具体地说,该程序调用

未定义的行为,任何事情都可能发生。在您目前使用的系统上,任何东西

似乎是打印657,但这不能保证。


程序表现出未定义的行为有两个原因,

和特殊行为。还有两个:


- 它在

范围内调用一个没有原型的可变函数。采用可变数量的
参数的函数 - 比如printf() - 必须在使用前正确声明
,或者未定义的行为结果。

声明printf()的最佳方式是#include

< stdio.h> ;.


- 它使用%d转换说明符,其值为

,而不是int。 printf()调用中的'main''

是指向名为`main''的函数的指针,而

函数指针不是'int''。当你告诉

printf()期望一个类型的参数(`int'')

并实际提供不同的东西(函数

指针),未定义的行为结果。


- 它无法以

a换行符''\ n''结束其最终(唯一)输出行。在某些实现中,

输出可能根本不会出现,除非每行

以换行结束。


- 它" ;从最后掉下来 `int'' - 值函数

main()没有返回'int''值。如果

环境试图使用main()

返回的值作为程序成功或失败的指示

(大多数环境都这样做),如果main()无法返回值,那么很可能导致
结果。


-
呃********* @ sun.com


这篇关于主要回报值stange问​​题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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