Is the possibility of both array[index] and index[array] a compiler feature or a language feature. How is the second one possible?
Answer
The compiler will turn
index[array]
into
*(index + array)
With the normal syntax it would turn
array[index]
into
*(array + index)
and thus you see that both expressions evaluate to the same value. This holds for both C and C++.
No comments:
Post a Comment