O'Reilly logo

C Primer Plus, Fourth Edition by Stephen Prata

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

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

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