When following the MIT 6.828 open course, there’s one C source code discussing pointers in Exercise 4 of lab 1.
There’s one line of code in pointers.c:
3[a] = 302;
Looks weird at first sight; but TCPL says in Chapter 5.3:
In evaluating a[i], C converts it to *(a+i) immediately; the two forms are equivalent.
So: a[i] and i[a] are equvalent (if i is a constant). 🙂
Comments