Stack and heap
Your program's memory has two regions you control.
The stack holds local variables. It is automatic: a frame appears when a function is called and disappears when it returns. It is fast, and it is small — typically 8 MB on Linux, 1 MB on Windows. You cannot decide its lifetime.
The heap is a large pool you request from explicitly. You ask for bytes, you get an address, and those bytes stay yours until you hand them back. Slower to allocate, but you choose the size at runtime and you choose the lifetime.
Use the heap when: you do not know the size until the program runs, the data must outlive the function that created it, or the data is too big for the stack.