Static and Dynamic Memory

Static memory is what you have seen and used so far: variables (including pointer variables) and arrays of fixed size. You can work with these blocks of memory in your program code using their names as well as their addresses (see Chapter 9, “Working with Pointers”).

With static memory you define the maximum amount of space required for a variable when you write your program:

char a[1000]; // Fixed at runtime.

Whether needed or not, all of that memory will be reserved for that variable and there is no way to change the amount of static memory while the program runs.

Dynamic memory is different. It comes in blocks without names, just addresses. It is allocated when the program runs, in chunks from a large pool that ...

Get C Programming: Visual Quickstart Guide now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.