Next: , Previous: , Up: Top   [Contents][Index]

16 Arrays

An array is a data object that holds a series of elements, all of the same data type. Each element is identified by its numeric index within the array.

We presented arrays of numbers in the sample programs early in this manual (see Array Example). However, arrays can have elements of any data type, including pointers, structures, unions, and other arrays.

If you know another programming language, you may suppose that you know all about arrays, but C arrays have special quirks, so in this chapter we collect all the information about arrays in C.

The elements of a C array are allocated consecutively in memory, with no gaps between them. Each element is aligned as required for its data type (see Type Alignment).

Next: , Previous: , Up: Top   [Contents][Index]