Chapter 7

Arrays

The variables we’ve used so far can store a single value. In this chapter, we’ll talk about a new type of variable capable of storing a number of values. This type is called array. An array may be multidimensional. We’ll focus on the simplest and most usual kinds; the one-dimensional and two-dimensional arrays. To introduce you to arrays, we’ll show you how to use arrays of integers and floating-point numbers. We’ll discuss other types of arrays, as well as their close relationship to pointers in later chapters.

Declaring Arrays

An array is a data structure that contains elements of the same data type. To declare a one-dimensional array, you must specify its name, the number of its elements, and their data type, like ...

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