O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required