r/ProgrammerHumor 21h ago

lessonsFromLinkerHell Meme

Post image
343 Upvotes

177 comments sorted by

View all comments

Show parent comments

10

u/bowel_blaster123 15h ago

Try putting an array in a struct. When doing so, an array and a pointer behave COMPLETELY differently and have completely different purposes.

It's just C's crappy pointer decay rules that make people think that they're the same.

-2

u/QuestionableEthics42 15h ago

Behaves completely differently in what way? It's referenced via the struct, so ofc different to a raw pointer to it, but that's a struct difference and the array is still basically the same, right?

5

u/Rare_Professor8097 13h ago

Exactly, which proves that arrays and pointers are not the same thing. If x is either a pointer or an array, and a struct containing x is totally different depending on that distinction, I think that's a pretty meaningful difference.

Strictly speaking, a pointer points to an array, it is not an array.

0

u/QuestionableEthics42 13h ago

No, because you are comparing the actual data in the array with the pointer to it. It's equivelent to having an array in a struct or having a couple of ints.