It is now time to gain a cursory understanding of how C organizes memory when a program is loaded and run. This discussion builds upon the Introduction to pointers section in Chapter 13, Using Pointers. Consider the following diagram:
This is a very simple conceptual view of a program's memory space. The operating system provides this space to the program when it is loaded to be run. The C runtime then divvies up the memory given to it into segments, each for a specific use. It consists of the following segments:
- System memory: This consists of system memory and system programs, as well as the addresses for all of the devices on the computer. This segment is mapped for all running programs so that there is only ever one copy of the system code in the overall system memory space. The system exclusively manages this memory.
- Program code: This is where the compiled program...