When we create an array on stack , say int arr[20]; , is it guaranteed that each cell of the array is 4 bytes apart in the memory ? Or it might happen that some of the cells are not allocated sequentially ?
When we create an array on stack , say int arr[20]; , is it guaranteed that each cell of the array is 4 bytes apart in the memory ? Or it might happen that some of the cells are not allocated sequentially ?
An array is guaranteed to be stored in contiguous memory. Pointer arithmetic is defined in such a way that
&arr[i] + 1 == &arr[i + 1]