本文介绍了谁能帮我解释一下这段代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 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推荐答案 一个好的编译器可以。我说(一直迂腐): 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的上下文中, 解释没什么。它甚至没有编译。即使你忽略了所有 警告,它也会调用未定义的行为,无论你获得什么结果都不能信任(特别是如果你看到恶魔飞出你的 b $ b鼻子)。 只是不要这样做,请不要试图从中吸取教训。 - 自然憎恶真空 - Brian Behlendorf在OSS上(开源,1999 O''Reilly和 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-infunction a??printfa??testbed.c:3: error: assignment makes integer from pointer withouta casttestbed.c:3: error: passing argument 1 of a??printfa?? makes pointerfrom integer without a casttestbed.c:3: warning: operation on a??aa?? may be undefinedtestbed.c:4: warning: control reaches end of non-void functionAs you can see, in the context of Standard C, there''s nothing tointerpret. It doesn''t even compile. Even if you ignore all thewarnings, it invokes Undefined Behaviour, and whatever result you getcannot be trusted (esp. in the case you see demons flying out yournose).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 andAssociates)<http://clc-wiki.net/wiki/Introduction_to_comp.lang.c> 也许,但它无效标准C甚至在编译时成功导致未定义的行为。Perhaps, but it''s not valid Standard C and even when compiledsuccessfully causes undefined behaviour. 这篇关于谁能帮我解释一下这段代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
06-19 22:45