I think it's fun to go through the "C expert programming" that I just delivered two days ago, the award for ioccc in chapter 8.10 in 1987.
Main () {printf (& UNIX ["/021% six/012/0"], (UNIX) ["have"] + "fun"-0x60 );}
The first technique used by the author here is not too obscure: "A [I] = I [a] = * (a + I)" is the interchangeable subscript operator.
But what is the old man's UNIX and UNIX?
I think about the most concealed corner of C in my mind. Is it a special symbol like trigraph? No
If the push is not successful, let's reverse the push. After compilation and running, the output is "Unix". In this case, "(UNIX) [" have "] +" fun "-0x60)" The result of this expression should be a char * pointing to "UN". Therefore, the value of "(UNIX) [" have "]-0x60" must be an integer of 1. Therefore, "(UNIX) the value of ["have"] "should be 0x61; this is suddenly open, 0x61 = 'A', the second character in" have, therefore, the Unix value must be 1.
Is this reverse push correct? Use GCC to check the code after Preprocessor processing only:
Whodare @ whodare :~ /Programming/C ++ $ gcc-e 1.c
Main ()
{
Printf (& 1 ["/021% six/012/0"], (1) ["have"] + "fun"-0x60 );
}
Correct. UNIX seems to be a predefined Marco with a value of 1. Google the keyword "GCC predefined Marco" and find the trusted information:
Http://gcc.gnu.org/onlinedocs/cpp/System_002dspecific-Predefined-Macros.html#System_002dspecific-Predefined-Macros
The original UNIX macro is a system-specific predefined macros provided by GCC, so this wonderful function can only work normally in * nix environment.
For more information, see the predefined Marco gcc-DM-e 1.C provided by GCC.
Along with historical documents, haha best one liner:
David KoRn
At&t Bell Labs
MH 3c-526b, at&t Bell Labs
Murray Hill, NJ
07974
USA
The judges believe that this is the best one line entry ever already ed.
Compile on a UN * x system, or at least using a C implementation that
Fakes it. Very few people are able to determine what this program
Does by visual inspection. I suggest that you stop reading this
Section right now and see if you are one of the few people who can.
Several points are important to understand in this program:
1) What is the symbol 'unix 'and what is its value in the program?
Clearly 'unix 'is not a function, and since 'unix' is not declared
To be a data type (such as int, Char, struct Foo, Enum ,...)
What must 'unix 'be?
2) What is the value of the symbol "have "? (Hint: The value is
Not 4 characters, or 'h', or a string) consider the fact that:
Char * X;
Defines a pointer to a character (I. e. An address), and that
The '= 'assigns things is compatible types. Since:
X = "have ";
Is legal C, what type of value is "have "?
3) Note that the following expressions yield the same value:
(UNIX) ["have"] + "fun"-0x60)
X [3] * (x + 3) * (3 + x)
Since addition is communitive. What can be said about the value:
3 [x]