> Write a C program which prints Hello World! without using a semicolon<p>Here's one way, cheating a bit by abusing the definition of "a C program which prints":<p><pre><code> /tmp$ gcc hw.c
hw.c:1:2: warning: #warning Hello world! [-Wcpp]
#warning Hello world!
</code></pre>
A more serious solution, though:<p><pre><code> /tmp$ cat hw.c
#include <stdio.h>
void main(void)
{
if (puts("Hello world!")) {}
}
/tmp$ gcc hw.c
/tmp$ ./a.out
Hello world!</code></pre>
<p><pre><code> #include <stdio.h>
int main()
{
float a = 12.5;
printf("%d\n", a);
printf("%d\n", *(int *)&a);
return 0;
}
</code></pre>
This program invokes undefined behaviour when it casts float\* to int\*, so technically it could print anything, or do something else. I'm not sure how using memcpy instead would impact the puzzle's point though.
One of these reminded me of my woeful attempts at IOCCC-like code, a Hello World implementation:<p><a href="http://students.mimuw.edu.pl/~dj189395/nhp/czynic/programy/tidbits/guess.c" rel="nofollow">http://students.mimuw.edu.pl/~dj189395/nhp/czynic/programy/t...</a>
Anyone else spot the uninitialized variable in the banner program?<p>Also:<p>> <i>What's the output of the following program. (No, it's not 10!!!) </i><p>What's the point of including a program that calls malloc without including a prototype for it, after asking the reader earlier answer why such a program segfaults on IA-64 but not IA-32?<p>(The answer is: a constraint is violated, requiring a diagnostic, because an int * object pointer is assigned the return value of malloc whose implicit declaration marks it as returning int. The comment issue is a red herring.)