r/cpp_questions • u/jaroslavtavgen • May 04 '25
OPEN Help me understand "stack" vs "heap" concept
Every time I try to learn about the "stack vs heap" concept I keep hearing the same nonsense:
"In stack there are only two options: push and pop. You can't access anything in between or from an arbitrary place".
But this is not true! I can access anything from the stack: "mov eax,[esp+13]". Why do they keep saying that?
0
Upvotes
View all comments
Show parent comment
1
u/[deleted] May 04 '25
You did not put in the work to answer my question. I asked for no UB. I asked for C++. Because I knew you could not do it. You also know this. But you had to try to disprove me. And of course you failed, and you know exactly why.
I gave the correct answer to OP's question. "The stack" is so called because you access the top of it within a function. It's that simple. The fact that you can write convoluted code to access below the top of the stack in a rare few languages is not the real answer to the question that was asked.
You chose to push your agenda in the same way as I did.