can i ask how are elements of an array stored in an memory?
How elements are stored in an array
Collapse
X
-
Tags: None
-
It is required that the elments be contiguous in memory. Otherwise, pointer calculations are not possible.
All arrays are one-dimensional.
int array[4]; //4 elements each element an int
is stored
0 1 2 3
int array[4][2]; //4 elements with each element an array of 2 int
0 1 0 1 0 1 0 1
0 1 2 3
The first index is the number of elements. Any other indexes just describe the element.
Comment