Module 09: Arrays & Multidimensional Memory Layout

Duration: 3.5 Hours • Core Data
1. 1D Contiguous Memory 1 / 4

1D Array Contiguous Memory & Pointer Decay

Why arr[i] is mathematically identical to *(arr + i)

An array is a contiguous block of homogeneous elements stored side-by-side in memory. In C, the name of the array automatically decays to a pointer to its first element (&arr[0]).

array_math.c
int arr[4] = {10, 20, 30, 40};

// Address calculation: Address of arr[i] = BaseAddress + (i * sizeof(type))
printf("%d\\n", arr[2]);     // 30
printf("%d\\n", *(arr + 2)); // 30 (Dereferencing base pointer + 2 elements)
printf("%d\\n", 2[arr]);     // 30 (Valid C: *(2 + arr) == *(arr + 2))