Arrays
Recall that an array is composed of a series of elements of one data type. You use declarations to tell the compiler when you want an array. An array declaration tells the compiler how many elements the array contains and what the type is for these elements. Armed with this information, the compiler can set up the array properly. Array elements can have the same types as ordinary variables. Consider the following example of array declarations:
/* some array declarations */ int main(void) { float candy[365]; /* array of 365 floats */ char code[12]; /* array of 12 chars */ int states[50]; /* array of 50 ints */ ... }
The brackets ([]) identify candy and the rest as arrays, and the number enclosed in the brackets indicates the number of ...
Get C Primer Plus®, Third 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.