Lesson 22: Dynamic memory — stack, heap & malloc
So far all our variables lived on the stack: they are created automatically, their size is fixed in advance, and they disappear when the function ends. Sometimes that's not enough — for example when you want an array whose size is known only at runtime. That's what the heap is for: you request memor