9 Pointers and Dynamic Arrays

Memory is necessary for all the operations of reason.

BLAISE PASCAL, Pensées

Introduction

A pointer is a construct that gives you more control of the computer’s memory. This chapter shows how pointers are used with arrays and introduces a new form of array called a dynamic array. Dynamic arrays are arrays whose size is determined while the program is running, rather than being fixed when the program is written.

Prerequisites

Section 9.1, which covers the basics of pointers, uses material from Chapters 2 through 6. It does not require any of the material from Chapters 7 or 8. Section 9.2, which covers dynamic arrays, uses material from Section 9.1, and Chapters 2 through 7. It does not require any of the material from Chapter 8.