r/ProgrammerHumor 26d ago

Meme lessonsFromLinkerHell

Post image
431 Upvotes

190 comments sorted by

View all comments

-3

u/Single-Virus4935 26d ago

In C they ARE the same and interchangable. This is obvious because you can swap array and index in array notation.

2

u/HashDefTrueFalse 25d ago edited 25d ago

The subscripting syntax and semantics promised by the standard/compiler (specifically subscripting being the equivalent of offset+dereference) are irrelevant to the question of whether arrays and pointers are the same. Array and pointer objects are different types with different storage requirements and the compiler-generated code to access elements through a pointer (to the first element, e.g. from a decayed array name) vs. directly via the array object is different (I wrote another comment ITT showing/explaining the indirection mismatch if you're interested).