Dynamic Memory

Lesson overview

Topics covered: malloc, calloc, realloc, free, sizeof, pointer casts.

Memory Management

Stack: automatic memory, cleared when function returns
Heap: manual allocation with malloc() and free()
int *p = (int *)malloc(sizeof(int) * 10);
Always free(p) when done to prevent leaks.

Article author: Arthur Isaev