这是如何与QUOT;!世界你好"工作方案? [英] How does this "hello world!" program work?

查看:138
本文介绍了这是如何与QUOT;!世界你好"工作方案?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

int main(void)
{ 
    return('yes', *"no", **main, *********printf) ("hello world!\n") *0; 
}

输出世界,你好!,但它是如何实际工作?

outputs hello world!, but how does it actually work?

推荐答案

两件事情真的:


  1. 函数指针不取消引用像其他指针。 *主要==主

  2. 一个逗号分隔的列表返回列表中的最后一个元素的值

因此​​,如果我们简化了指针:

So if we simplify the pointers:

int main(void)
{ 
    return('yes', *"no", main, printf) ("hello world!\n") *0; 
}

和使用的最后一个元素中的列表作为该列表的值

And using the last element in the list as the value of the list

int main(void)
{ 
    return printf("hello world!\n") *0; 
}

的printf 返回打印的字符数

int main(void)
{ 
    return 13 *0; 
}

和13 * 0作为练习留给读者。

And 13*0 is left as an exercise to the reader.

这篇关于这是如何与QUOT;!世界你好"工作方案?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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