-
C Puzzle -Printf
How output from below printf was
"Hello! how is this? super
That is C! "
Code:
#include <stdio.h>
int main()
{
int a=3, b = 5;
printf(&a["Ya!Hello! how is this? %s\n"], &b["junk/super"]);
printf(&a["WHAT%c%c%c %c%c %c !\n"], 1["this"],
2["beauty"],0["tool"],0["is"],3["sensitive"],4["CCCCCC"]);
return 0;
}
This is taken from A Quiz
-
Here's a simpler example using the same principal -
Code:
int a[5] = { 1, 2, 3, 4, 5 };
int i = 3;
printf("%d", i[a]); /* NOT a typo */
-
What about this??
printf(&a["Ya!Hello! how is this? %s\n"], &b["junk/super"]);
&a["WHAT%c%c%c %c%c %c !\n"]
-
Before throwing strings into the question, do you understand my simpler example?
-
http://c-faq.com/aryptr/joke.html
I hope this wasn't a question from anyone serious (like say a prospective employer)