Chapter 6. Using Arrays

<feature>
  • Learn how to define and initialize an array

  • Learn how to access array elements

  • See how to use loops with arrays

  • Find and replace text and formatting

  • Learn to use multi-dimensional arrays

</feature>

Why Use Arrays?

With the exception of character strings, the data types and variables you’ve seen up to this point have been simple data types that store only a single value. Consider these two variables:

char ch = 'B';
int num = 134;

Variables like these are called scalar variables. They can contain only a single value at a time, and you can’t subdivide them further; they are elemental. An array is a group of variables having the same data type.

In writing efficient programs, it’s often convenient to have an array of variables ...

Get Practical C++ now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.