Summary

An array is a set of elements that all have the same data type. Array elements are stored sequentially in memory and are accessed by using an integer index (or offset). In C, the first element of an array has an index of 0, so the final element in an array of n elements has an index of n - 1. It's your responsibility to use array indices that are valid for the array, because neither the compiler nor the running program checks.

To declare a simple one-dimensional array, use this form:

					type name[size];

Here, type is the data type for each and every element, name is the name of the array, and size is the number of elements. Traditionally, C has required that size be a constant integer expression. C99 allows you to use a non-constant integer ...

Get C Primer Plus, Fourth Edition 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.