Possible Duplicate:
In C arrays why is this true? a[5] == 5[a]
3["zdvnngfgnfg"];
Possible Duplicate:
In C arrays why is this true? a[5] == 5[a]
3["zdvnngfgnfg"];
It's equivalent to
"zdvnngfgnfg"[3];
which is legal and means "take the address of that literal and add 3*sizeof(char)
to it". Will have no effect anyway.
Also see this very similar question.
arr[i] is parsed as *(arr+i) which can be written as *(i+arr) and hence i[arr]
Now "strngjwdgd" is a pointer to a constant character array stored at read only location.
so it works!!
The string literal(array
) decays to a pointer of type char*
. Then you take the fourth element:
3["zdvnngfgnfg"] == "zdvnngfgnfg"[3]
Why you can write the subscript infront of the array is another question: