Interesting C thingy

Jason Gurtz jason at
Mon Aug 9 09:52:17 PDT 2004

On 8/9/2004 12:14, Kevin P. Fleming wrote:
> Jason Gurtz wrote:
>> What does printf("%c\n",0["unix"]); output and why?
> My guess would be that is prints "u" followed by a newline, but I can't 
> say for sure why I think that :-)

Well, you're right.  I'll give it away...

"x[y]" is, more or less, shorthand for *(x+y).  Since "unix" in this
case is an expression of type array (of its self) and array names ==
arrayName[0] you get a pointer to unix[0+0] or "u".

Actualy, I learned a whole bunch of things there by that simple little
statement.  Maybe I'll spring it on my Intermediate C++ class this
comming semester.

Oh, and BTW, this example was originaly given at a USENIX C obfuscation
contest (not sure if it won or not).




More information about the lfs-chat mailing list