June 2018
Beginner
510 pages
13h 7m
English
An array is a list consisting of the same data types. The array elements are stored in contiguous locations in the memory, which makes it easy to access array elements. The following defines an integer array of three elements, and each element of this array occupies 4 bytes in the memory (because an integer is 4 bytes in length):
int nums[3] = {1, 2, 3}
The array name nums is a pointer constant that points to the first element of the array (that is, the array name points to the base address of the array). In a high-level language, to access the elements of the array, you use the array name along with the index. For example, you can access the first element using nums[0], the second element using nums[1], and so on: