← Back to list

The Biggest Misconception About Arrays in C

Almost every programmer learns that arrays are used with the indexing operator.

Budi Raharjo · 2026-07-18 18:03 · 1 claps · 2.4 min read
#c-programming #arrays #pointers-in-c #c-mental-model #c-programming-language
Open on Medium ↗
Wiki topics: 💻 · Programming

The Biggest Misconception About Arrays in C

Almost every programmer learns that arrays are used with the indexing operator.

int numbers[] = {10, 20, 30, 40, 50};

printf("%d\n", numbers[2]);

The phrase we often hear is:

The [] operator is used to access array elements.

This explanation isn’t wrong. However, it hides something far more interesting.

The truth is, C does not have a standalone array indexing mechanism. What C has is only pointer arithmetic. The [] operator is merely a more readable way of writing it.

In other words, when the compiler sees the following code,

numbers[2]

the compiler treats it as

*(numbers + 2)

Not as a special operation that only applies to arrays.

Look closely at that expression. The compiler doesn’t start by looking for “the element at index 2.” The first thing it does is form the pointer expression numbers + 2, which produces the address of the element at index 2. After that, the dereference operator (*) retrieves the value stored at that address.

The first step is calculating a memory address.

numbers + 2

Which means:

Start from the address of the first element, then move forward by two elements.

The result is a pointer.

Only then does the dereference operator (*) fetch the contents of memory at that address.

In other words,

numbers[2]

is treated as:

*(numbers + 2)

then:

retrieve the value at that address

The [] operator turns out to be nothing more than a combination of two existing operations:

  • pointer arithmetic
  • dereference

Nothing more.

The consequences are quite surprising.

If numbers[i] is identical to *(numbers + i) then mathematically, numbers + i is the same as i + numbers. Because addition is commutative. As a result, numbers[i] and i[numbers] are identical expressions. So, the following code is valid.

printf("%d\n", 2[numbers]);

Most programmers never write code like that — and indeed, they shouldn’t. However, the fact that this syntax is legal reveals something more important.

The [] operator does not "belong" to arrays. It is simply another notation for pointer arithmetic followed by dereference.

This mental model changes how you view arrays in C. An array is not an object with built-in indexing capabilities like in many modern languages. Instead, an array is just a contiguous block of memory. What’s really doing the work is the pointer.

The array only provides the starting address of that memory block. Once this perspective takes hold, many other things start to make sense.

Why pointer arithmetic works on arrays.

Why an array name often “decays” into a pointer when passed to a function.

Why sizeof(numbers) differs from sizeof(ptr).

Why C doesn’t perform bounds checking.

It all stems from one simple fact:

In C, indexing is not an array feature. Indexing is just pointer arithmetic written in a more readable form.

Learning syntax is important. However, understanding why the syntax exists is often far more valuable.

Once you see that numbers[i] is just another form of *(numbers + i), arrays no longer appear as a standalone concept. They become part of C's memory model—far more consistent and elegant.

And often, a single shift in thinking like this is more valuable than memorizing dozens of syntax rules.

Think Like a C Programmer

Finally, try to answer one question without running the program.

int numbers[] = {10, 20, 30, 40, 50};

printf("%d\n", numbers[2]);
printf("%d\n", 2[numbers]);

Does this program: A. Fail to compile B. Print two different values C. Print the same value

If your answer is C, it means you’re starting to see arrays the way the compiler sees them.

Photo by Declan Sun on Unsplash

Photo by Declan Sun on Unsplash


메타데이터
post_id
0ed9cc405da6
slug
the-biggest-misconception-about-arrays-in-c-0ed9cc405da6
url
https://medium.com/@codepub/the-biggest-misconception-about-arrays-in-c-0ed9cc405da6
canonical_url
https://medium.com/@codepub/the-biggest-misconception-about-arrays-in-c-0ed9cc405da6
author_url
https://medium.com/@codepub
status
ok
fetched_at
2026-07-29 08:46:23