O'Reilly logo

Sams Teach Yourself C++ in One Hour a Day, Sixth Edition by Bradley Jones, Siddhartha Rao, Jesse Liberty

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

Chapter 4. Managing Arrays and Strings

In previous lessons, you declared a single int, char, or other object. However, you may want to declare a collection of objects, such as 20 ints or a litter of Cats.

In this lesson, you will learn

  • What arrays are and how to declare them

  • What strings are and how to use character arrays to make them

What Is an Array?

An array is a sequential collection of data storage locations, each of which holds the same type of data. Each storage location is called an element of the array.

You declare an array by writing the type, followed by the array name and the subscript. The subscript is the number of elements in the array, surrounded by square brackets. For example:

long LongArray[25];

declares an array of 25 long integers, ...

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