Interesting C thingy
lfs-01 at thewizardstower.org
Mon Aug 9 09:56:56 PDT 2004
* Jason Gurtz <jason at tommyk.com> [2004-08-09 16:42]:
> This came up on another list:
> What does printf("%c\n",0["unix"]); output and why?
> Being a beginning C programmer I found out something new and interesting
> in the answer. Heh, people also said it might be C code generated by a
> perl programmer which, after knowing the answer I could see.
Interesting; I didn't know that and I don't know for sure why (stupid
google can't search for "0[" :)
Not surprisingly, printf("%c\n",1["unix"]); prints n<newline>, and
char *str = "unix";
also prints n<newline>.
printf("%c\n",9[str]); only prints the newline, i expected it to
More information about the lfs-chat