I just saw this here
#include
int main(int argc, char *argv[printf(\"Hello, world!\\n\")]) {}
What this does is print \"Hello
The code makes use of C99's variable-length array feature, which lets you declare arrays whose size is known only at run-time. printf
returns an integer equal to the number of characters that were actually printed, so the code prints "Hello, world!" first and uses the return value as the size of argv
. The main
function itself does nothing. The actual call to printf
itself probably goes into the startup code generated by the compiler, which in turn calls main
.
Edit: I just checked the disassembly of the code generated by gcc
and it appears that the call to printf
goes inside main
itself, before any other code.