EDIT: Thanks for the link to the previous StackExchange question, the answer is that a[b] is defined as *(a+b), such that "a"[0] = 0["a"] = *("a"+0). I guess this works because "a" is a pointer? So I can't say:
int i;
i[0];
But I can say:
int i;
i["a"];
I'm trying to understand how in the heck this code compiles and what is happening. Any hints would be greatly appreciated. Also, if you know of a good reference for understanding what's really going on in the C language feel free to drop it on me.
Code is here:
int i;
main()
{
int j;
int k;
j=i["a"]; //printf says j is 97!
k=i["b"]; //printf says k is 98!
}
So... what the heck is going on?! I declared "i" as an integer and then I treat it as an array with no compilation error/warning and I enter a string as the argument to the array and still no problems? Anyone have any ideas? Thanks in advance.