In the examples so far, the programs have only had as much memory available as has been declared for the variables at compile time. This is referred to as static allocation. If any additional memory is needed at runtime, it becomes necessary to use dynamic allocation. The C standard library provides several functions for managing dynamically allocated memory, including malloc, free, realloc, and calloc. These functions are found in the stdlib.h header file.
19. Memory Management
Get Modern C Quick Syntax Reference: A Pocket Guide to the Language, APIs, and Library now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.