你好用C世界上没有分号,没有IF / WHILE / FOR语句 [英] hello world in C without semicolons and without IF/WHILE/FOR statements

查看:130
本文介绍了你好用C世界上没有分号,没有IF / WHILE / FOR语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的朋友说,这是可以写一个C程序将打印的Hello World没有 IF / WHILE / FOR 和没有分号。最小的研究后,我告诉她这是不可能的。这可能吗?

My friend says it's possible to write a C program that will print "hello world" without IF/WHILE/FOR and without semicolons. After minimal research I told her it was not possible. Is it possible?

推荐答案

我一直在试图找到一个包含文件中偷一个分号的便携式的方式。这个工作在Linux下:

I've been trying to find a "portable" way of stealing a semicolon from an include file. This works under Linux:

int main(int ac, char **av)
{
#define typedef
#define uint8_t a[printf("hello world\n")]
#include <stdint.h>
}

这会导致一个的typedef unsigned char型uint8_t有成为我的printf。

This causes the one typedef unsigned char uint8_t to become my printf.

这是另一种工作技巧是的#define 客场每个标准stdint型,比如 stdint.h 减少到一堆分号。

Another trick that worked was to #define away every standard stdint type such that stdint.h reduces to a bunch of semicolons.

在FreeBSD这两个秋天的平板,因为它使用的是专用的中间类型(如 __ uint8_t有),这意味着除去的typedef未能在所列出的例子,prevents我从成功地删除所有非分号在另一种情况下。

Both of these fall flat on FreeBSD because it uses private intermediate types (like __uint8_t) which means that removing typedef fails in the quoted example and prevents me from successfully removing all non-semicolons in the other case.

现在看来似乎应该可以从包含文件干净偷一个分号。任何人都可以在我尝试改进?

It seems like it should be possible to steal a semicolon cleanly from an include file. Can anyone improve on my attempt?

这篇关于你好用C世界上没有分号,没有IF / WHILE / FOR语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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