O'Reilly logo

C by Nikolaos D. Tselikas, George S. Tselikis

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 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 this:

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