← Strings and ArraysC PROGRAMMING 1.3.E

Arrays vs Pointers

Where the two are interchangeable and where they genuinely are not.

StatusCollected

Four pieces pinning down exactly where "arrays are just pointers" is true and where it very much isn't.

int arr[5];
int *p = arr;

printf("%zu\n", sizeof(arr));   /* 20 — the full array */
printf("%zu\n", sizeof(p));     /* 8 — just a pointer */

arr = p;    /* compile error — arr is not a modifiable value, p is */
p = arr;    /* fine — p can be reassigned to point anywhere */

Indexing (arr[i] / p[i]) and dereferencing behave identically either way — that's the part that makes them feel interchangeable. sizeof and reassignment are where they split: an array name is a fixed label for a fixed block of memory, not a variable that can be pointed elsewhere, while a pointer genuinely is just a variable holding an address.

Notes from readers

Comments — via GitHub