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).
|• Accessing Array Elements||How to access individual elements of an array.|
|• Declaring an Array||How to name and reserve space for a new array.|
|• Strings||A string in C is a special case of array.|
|• Array Type Designators||Referring to a specific array type.|
|• Incomplete Array Types||Naming, but not allocating, a new array.|
|• Limitations of C Arrays||Arrays are not first-class objects.|
|• Multidimensional Arrays||Arrays of arrays.|
|• Constructing Array Values||Assigning values to an entire array at once.|
|• Arrays of Variable Length||Declaring arrays of non-constant size.|