If a=3 and b=5 what does this imply?
printf(&a["Ya!Hello! how is this? %s\n"], &b["junk/super"]);
I know that arr[4] means *(arr+4) so I need to know what does an expression like "hi there" imply?
EDIT – Question in probably clearer terms:
When a string is used as an array subscript what value does it convey ?
Why is output of above Hello! how is this? super ?
That implies, the printf becomes equivalent to this:
which will print:
Online demo : http://ideone.com/PVzUP
Explanation:
When we write
char s[]="nawaz;and thens[2]means 3rd character in the strings. We can express this by writing"nawaz"[2]which also means 3rd character in the string"nawaz". We can also write2["nawaz"]which also means 3rd character in the string. In your code, theprintfuses the last form, i.e of the form of2["nawaz"]. Its unusual, though.So
a["Ya!Hello! how is this? %s\n"]means 4th character in the string (as the value ofais 3), and if you add&infront ofathen&a["Ya!Hello! how is this? %s\n"]returns the address of the 4th character in the string, that means, in the printf it becomes equivalent to this:And I hope you can interpret the rest yourself.