最小的“C”节目!! [英] Smallest "C" Program !!

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

问题描述

Hello Folks,


我在我的一项能力倾向考试中遇到过这个目标,那就是

什么可能是最小的C&b。程序?


而且,正如我们所知,最小的程序意味着,它应该执行

单一陈述,我写了; (分号),所以,程序输出将显示空白屏幕。


但朋友们,我不确定,有没有人有完美的解决方案?


谢谢..

解决方案

Dev< kr ********* *@gmail.com>写道:

我在我的一项能力考试中遇到过这个目标,那就是什么可能是最小的C"程序?

而且,正如我们所知,最小的程序意味着,它应该执行单个语句,


错误。我们知道,最小的程序至少应该有一个main()

函数。

但朋友们,我不确定,有没有人有完美的解决方案?



int main(无效){return 0;}

-

:wq

^ X ^ Cy ^ K ^ X ^ C ^ C ^ C ^ C


" Dev" < KR ********** @ gmail.com>写道:

Hello Folks,

我在我的一项能力考试中遇到过这个目标,那就是什么可能是最小的 ; C"程序?

而且,正如我们所知,最小的程序意味着,它应该执行单个语句,我写了;。 (分号),所以,程序输出会显示空白屏幕。

但朋友们,我不确定,有没有人有完美的解决方案?



我认为这可能取决于C实现是否适用于

" hosted" (例如,台式PC)或独立式 (例如嵌入式)

系统。你的程序编译好了(用gcc),但给了我undefined

对main的引用在链接阶段。


假设你不需要main()的系统,那么我认为你

可以将尺寸再减少100 %省略;。


-


John Devereux


Ico写道:

Dev< kr ********** @ gmail.com>写道:

我在我的一项能力考试中遇到过这个目标,那就是什么可能是最小的C"程序?

而且,正如我们所知,最小的程序意味着,它应该执行单个语句,



错误。我们知道,最小的程序至少应该有一个main()
函数。

但朋友们,我不确定,有没有人有完美的解决方案?


int main(void){return 0;}




你甚至可以省略return 0; 。见ISO / IEC9899 5.1.2.2.3。


Tom


Hello Folks,

I had faced this objective in one of my aptitude exams, that
"What could be the smallest "C" program?

And, as we know, smallest program means, it should execute
single statement, I wrote ";" (Semicolon), so, program output will
display blank screen.

But Friends, I am not sure, Does anyone has perfect solution?

Thanks..

解决方案

Dev <kr**********@gmail.com> wrote:

I had faced this objective in one of my aptitude exams, that
"What could be the smallest "C" program?

And, as we know, smallest program means, it should execute
single statement,
Wrong. As we know, the smallest program should at least have a main()
function.
But Friends, I am not sure, Does anyone has perfect solution?



int main(void){return 0;}
--
:wq
^X^Cy^K^X^C^C^C^C


"Dev" <kr**********@gmail.com> writes:

Hello Folks,

I had faced this objective in one of my aptitude exams, that
"What could be the smallest "C" program?

And, as we know, smallest program means, it should execute
single statement, I wrote ";" (Semicolon), so, program output will
display blank screen.

But Friends, I am not sure, Does anyone has perfect solution?



I think it may depend on whether the C implementation is for a
"hosted" (e.g. Desktop PC) or "freestanding" (e.g. embedded)
system. Your program compiled OK (with gcc) but gave me "undefined
reference to main" at the link stage.

Assuming a system where you do not need main(), then I would think you
could reduce the size by a further 100% by omitting the ";".

--

John Devereux


Ico wrote:

Dev <kr**********@gmail.com> wrote:

I had faced this objective in one of my aptitude exams, that
"What could be the smallest "C" program?

And, as we know, smallest program means, it should execute
single statement,



Wrong. As we know, the smallest program should at least have a main()
function.

But Friends, I am not sure, Does anyone has perfect solution?



int main(void){return 0;}



you can even omit "return 0;". See ISO/IEC9899 5.1.2.2.3.

Tom


这篇关于最小的“C”节目!!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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