Arrays and pointers — array name decays to pointer
WHAT is "decay"?
The three famous exceptions where decay does NOT happen (the name stays a full array):
- ==
sizeof arr== → gives total bytes of the whole array, not pointer size. - ==
&arr== → givesT(*)[N], a pointer to the whole array, notT**. - The string literal used to initialize a
char[](it stays an array there).
WHY does C do this?
HOW does indexing actually work? (derive from scratch)
We claim arr[i] is defined as *(arr + i). Let's build it.
Step 1 — What is arr in arr + i?
Why this step? In the expression arr + i, arr is used as a value → it decays to &arr[0], type T*.
Step 2 — Pointer arithmetic scales by element size.
Why this step? Adding i to a T* does not add i bytes; it adds i elements. The compiler knows sizeof(T), so:
Step 3 — Dereference.
Why this step? *(arr + i) reads the T stored at that computed address — exactly the -th element.
So by the C standard:

Worked Examples
Common Mistakes (Steel-man)
Flashcards
What does "array decays to pointer" mean?
T[N] is auto-converted to a T* equal to &arr[0].Name the 3 contexts where an array does NOT decay.
sizeof arr, &arr, and a string literal initializing a char[].What is arr[i] defined as in C?
*(arr + i) — pure pointer arithmetic.Why does 3[arr] compile and equal arr[3]?
arr[i] == *(arr+i) == *(i+arr) == i[arr]; addition is commutative.Inside void f(int arr[]), what is the real type of arr?
int * — the parameter array syntax is rewritten to a pointer; size info is lost.sizeof(a) for int a[10]? And sizeof(p) for int *p=a?
Type of arr vs &arr for int arr[5]?
int* vs int(*)[5].Why does pointer +1 move different byte-distances for p vs &arr?
int* vs 20 bytes for int(*)[5].Can you write arr = p;? Can you write p = arr;?
Recall Feynman: explain to a 12-year-old
Imagine a train of 10 boxcars sitting at a station platform. The train's name painted on the side just tells you "the front of this train is right here." When you tell a friend about the train by name, you're really just pointing at where it starts — they can walk down the cars from there. That "pointing at the front" is decay: the name becomes an arrow to box #0. But if you ask "how long is the whole train?" (sizeof), the station map still knows it's 10 cars — that special question doesn't get fooled by the arrow.
Connections
- Pointer Arithmetic — decay is why
arr+iworks. - Passing Arrays to Functions — the practical fallout of decay.
- sizeof Operator — the #1 decay exception.
- Multidimensional Arrays — decay only peels off the outermost dimension (
int[3][4]→int(*)[4]). - Strings in C —
char*vschar[]and literal decay. - Memory Layout and Addresses — contiguous boxes underlie all of this.
Concept Map
Hinglish (regional understanding)
Intuition Hinglish mein samjho
Dekho, C mein array ek dabbon ki line hai jo memory mein side-by-side rakhe hote hain. Jab tum array ka naam likhte ho (jaise a), zyada-tar jagah par C tumhe poori line nahi deta — wo bas ek address de deta hai jo bolta hai "line yahaan se shuru hoti hai". Yahi address pehle element ka pointer hota hai (&a[0]). Isi automatic conversion ko decay kehte hain. Yaad rakho: array khud pointer nahi hai, bas naam use karte hi pointer ki tarah behave karne lagta hai.
Indexing ka asli raaz: a[i] ka matlab compiler ke liye literally *(a + i) hai. a decay hoke base address banta hai, phir +i se compiler i * sizeof(element) bytes aage jaata hai (bytes nahi, elements count hote hain!), aur * se wahaan ki value padh leta hai. Isi wajah se 3[a] bhi chal jaata hai aur a[3] ke barabar hota hai — kyunki jodna (addition) dono taraf same hai.
Sabse important exceptions teen hain (mnemonic: S.A.S. — Sizeof, Ampersand, String-literal). sizeof(a) poore array ke bytes deta hai (decay nahi hota), aur &a poore array ka pointer int(*)[5] deta hai — same number wala address, par alag type, isliye +1 karne par 20 bytes jump karta hai (5 ints ek saath).
Practical baat: jab array ko function mein bhejte ho (void f(int arr[])), wo andar chupke se int *arr ban jaata hai — size kho jaata hai. Isiliye exam aur real code dono mein length alag se pass karo (f(a, n)). Yeh chhoti si baat na samajhne par bahut bugs aate hain, toh isko pakka rakho!