####Stack vs Heap in C-languages
Stack
A stack is memory set aside for running code.
Typically, calls to functions create temporary variables.
These variables are stored on the stack.
Stacks are a LIFO (last in, first out) structure.
Heap
The heap is used for dynamic memory allocation.
It has no particular order and so is more difficult to manage than the stack.
Example
Non-dynamic variables are created on the stack:
{ // new block of code
int age = 4;
} // age is on stack, will go out of scope here and be de-allocated
Dynamic variables are created on the heap. In C:
int *age = malloc(sizeof(int));
*age = 4;
// -- do things --
free(age);
In C++:
Age *age = new Age(4);
// -- do things --
delete age;