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

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

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

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