谁能帮我解释一下这段代码? [英] Who can help me to interprete this code?

查看:54
本文介绍了谁能帮我解释一下这段代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

main(a)

{

printf(a,34,a =" main(a){printf(a,34,a =%c% s%c,34);}",34);

}

执行后,它打印自己的代码

main(a)
{
printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}" ,34);
}
After executing it , it prints itself''s code

推荐答案

wi ****** *****@gmail.com 认为:
wi************@gmail.com opined:
main(a)
{/> printf(a,34,a =" ; main(a){printf(a,34,a =%c%s%c,34);}",34);
}
main(a)
{
printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}" ,34);
}




一个好的编译器可以。我说(一直迂腐):


testbed.c:2:警告:返回类型默认为??凹陷??

testbed .c:在函数中?? ?? maina ??:

testbed.c:3:警告:隐式声明函数a ?? printfa ??

testbed.c: 3:警告:内置不兼容的隐式声明

函数a ?? printfa ??

testbed.c:3:错误:赋值从指针生成整数而不是

a cast

testbed.c:3:错误:传递参数1的?? printfa ??从没有投射的整数制作指针



testbed.c:3:警告:操作a ?? aa ??可能是未定义的

testbed.c:4:警告:控制到达无效功能的结束


如您所见,在标准C的上下文中,

解释没什么。它甚至没有编译。即使你忽略了所有

警告,它也会调用未定义的行为,无论你获得什么结果都不能信任
(特别是如果你看到恶魔飞出你的< br $> b $ b鼻子)。


只是不要这样做,请不要试图从中吸取教训。


-

自然憎恶真空

- Brian Behlendorf在OSS上(开源,1999 O''Reilly和< br $> b $ b员工)


< http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>



A good compiler could. Mine says (with pedantic all the way up):

testbed.c:2: warning: return type defaults to a??inta??
testbed.c: In function a??maina??:
testbed.c:3: warning: implicit declaration of function a??printfa??
testbed.c:3: warning: incompatible implicit declaration of built-in
function a??printfa??
testbed.c:3: error: assignment makes integer from pointer without
a cast
testbed.c:3: error: passing argument 1 of a??printfa?? makes pointer
from integer without a cast
testbed.c:3: warning: operation on a??aa?? may be undefined
testbed.c:4: warning: control reaches end of non-void function

As you can see, in the context of Standard C, there''s nothing to
interpret. It doesn''t even compile. Even if you ignore all the
warnings, it invokes Undefined Behaviour, and whatever result you get
cannot be trusted (esp. in the case you see demons flying out your
nose).

Just don''t do it, and please don''t try to learn from it.

--
"Nature abhors a Vacuum"

-- Brian Behlendorf on OSS (Open Sources, 1999 O''Reilly and
Associates)

<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c>


这是Quine。


:quine:/ kwi:n / / n./ [来自逻辑学家Willard van Orman的名字

Quine,来自Douglas Hofstadter]一个程序,它生成一份

自己的源文本作为完整输出。


我不太了解它。

但你可以从
http://www.n yx.net/~gthompso/quine.htm

It''s a Quine.

:quine: /kwi:n/ /n./ [from the name of the logician Willard van Orman
Quine, via Douglas Hofstadter] A program that generates a copy of its
own source text as its complete output.

don''t know much about it.
but u can read from
http://www.nyx.net/~gthompso/quine.htm


wi ************ @ gmail.com 写道:
main(a)
{
printf(a,34,a =" main(a){printf(a,34,a =%c%s%c,34);}" ,34);
}
执行后,它打印自己的代码
main(a)
{
printf(a,34,a="main(a){printf(a,34,a=%c%s%c,34);}" ,34);
}
After executing it , it prints itself''s code




也许,但它无效标准C甚至在编译时成功导致未定义的行为。



Perhaps, but it''s not valid Standard C and even when compiled
successfully causes undefined behaviour.


这篇关于谁能帮我解释一下这段代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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