So far, we have managed to write programs that only use global and local variables. In C-speak, these are called static and automatic memory allocation, and static memory allocation lasts the lifetime of the program. In contrast, automatic variables are deleted when you return from the function you defined them in. In practice, automatic means stack allocated, although the C standard doesn’t require there to be a stack. The third type of memory is dynamic memory, which is the memory you allocate on the heap in the idealized memory model we saw in Chapter 2. This is the memory you ...
Get Pointers in C Programming: A Modern Approach to Memory Management, Recursive Data Structures, Strings, and Arrays 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.