Dynamic Memory Allocation in C
Dynamic memory allocation allows programs to request memory during runtime.
Important functions are:
- malloc()
- calloc()
- realloc()
- free()
These functions are declared in stdlib.h.
malloc()
Allocates a block of memory.
calloc()
Allocates memory for multiple elements and initializes the allocated bytes to zero.
realloc()
Changes the size of a previously allocated block.
free()
Releases dynamically allocated memory.