How the computer handles variables
3 min readJun 25, 2020
--
I write down the code every day, but internally I didn’t know how the computer worked.
So I’m going to organize what I’ve studied about how computers handle variables.
Program memory address
In order for a program to run on a computer, the program must be loaded into memory. Therefore, the program must have enough memory space to cover its size.
A typical computer operating system manages memory space by dividing it into four categories
Global Variable
- Global variables are variables that are accessible anywhere in the program.
- The main functions is allocated to memory at the same time as the program starts even before it is excuted.
- The larger the program size, the more complex the program can be due to global variables.
- Loaded into the data area of memory.
Static variable
- Static variables are those that are accessible only in certain blocks.
- When the program runs, it is allocated to memory and released from memory where the program is terminated.
- Loaded into the data area of memory.
Local variable
- Local variables are those that can only be accessed from certain blocks in a program.
- Each time a function is executed, it is allocated to memory and released from memory when the function is terminated.
- It is recorded in the stack…