<<< Stack memory segment | Index | What is a local variable? >>> |
Heap is where the dynamically allocated variables are stored in a C program.
C++ uses its own facility named free store to dynamically allocate memory.
For example,
#include <iostream> int main() { std::cout << "how many numbers would you like to allocate? "; int count; std::cin >> count; int* memory_block = new int[ count ]; std::cout << "your block of memory begins at address " << memory_block << '\n'; return 0; }
<<< Stack memory segment | Index | What is a local variable? >>> |