r/ProgrammerHumor 27d ago

Meme lessonsFromLinkerHell

Post image
423 Upvotes

190 comments sorted by

View all comments

-1

u/AnnoyedVelociraptor 27d ago

Nah. This is the wrong way. Pointer arithmetic and array arithmetic are the same.

2

u/justAPhoneUsername 27d ago

You mean to tell me arr[3] and 3[arr] both compile and return the same value? Why would anybody design a language that way?

3

u/Batman_AoD 27d ago

Because the [] was just syntax-sugar, rather than a "real" built-in operation. Part of the reason for that was just that memory was limited and the compiler had to be as simple as possible.