Skip to content →

C a[i] vs i[a]

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:

Looks weird at first sight; but TCPL says in Chapter 5.3:

So: a[i] and i[a] are equvalent (if i is a constant). 🙂

Published in OS

Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.