O'Reilly logo

C Programming: Visual Quickstart Guide by Marc Liyanage, Larry Ullman

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

Introduction to Arrays

Whereas numbers and characters are scalar variables—meaning they contain only a single value at a time—arrays are a more complex structure. An array allows you to store a series of values, all under the heading of one variable. It's perhaps easiest to think of arrays as a two-column table (Table 6.1).

Table 6.1. Arrays are like tables with two columns: a numeric index (or key) and its associated value.
A Simple Array
KeyValue
098.5
174.3
282.0

Arrays consist of key-value pairs, each pair constituting an element. By referencing a specific key (also called its index), you can obtain that corresponding value.

You create an array much like any other variable: by giving it a type and a name. The type will apply to every element in ...

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