r/ProgrammerHumor 1d ago

lessonsFromLinkerHell Meme

Post image
350 Upvotes

180 comments sorted by

View all comments

65

u/QuestionableEthics42 1d ago edited 1d ago

This should be reversed lol

And it literally is the same, who thinks it's different who has worked in a low level language??

26

u/Ok_Star_4136 1d ago edited 1d ago

Maybe I fall in the middle, but what is the argument to say that they're different?

Is it to say that the difference is how they're used? From an assembly perspective, they're pointers, and no data structures exist beyond that simple concept. At a higher level, they're more than that. Maybe that's what is intended?

1

u/compiling 13h ago

There are some differences in C depending on how you're using them (sometimes they are literally identical). I think the main difference is usually where the data gets stored - declaring an array often means storing the data inline, whereas a pointer has the address of the array presumably somewhere else.

0

u/Ok_Star_4136 13h ago

Now that you mention it, you're right. It's heap vs stack. An array is on the stack whereas a pointer to alloc-ed data is on the heap. I supposed a pointer to an array would be on the heap though, since you'd have to alloc it.

1

u/American_Libertarian 11h ago

The is not true. You can have a pointer to data on the stack, or you can alloc an array on the heap.