Arrays, Pointers, and Pointer Arithmetic

You've already learned about arrays (in Chapter 6, “Working with Arrays”) and how to use the square brackets to access individual elements (the square brackets are technically referred to as the subscription operator). Now that you have an understanding of pointers, you'll learn how to use them to access array elements by performing calculations on the base address of the array. Such address calculations are called address or pointer arithmetic.

What is an array's base address? The elements of an array are laid out sequentially in memory. An array's base address is simply the address of the array's first element (Figure 9.13).

Figure 9.13. An array's base address (stored in the pointer b) is the location ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.