There are 5 main areas of memory allocation for C languages:
1. Stack area : When executing a function, a local variable within the function (not including the static variable), the function return value of the storage unit is created on the stack area. These storage units are automatically freed at the end of the function execution. The stack memory allocation operation is built into the processor's instruction set, which is highly efficient, but allocates limited memory capacity.
2, heap area : The program in the run time with malloc (calloc, realloc, etc.) application of memory, to be the programmer's own responsibility to free up memory.
3. Static storage : Store global variables and static variables. The program is compiled at the time it is distributed, and exists during the entire run of the program.
4, constant area : integer constants, floating-point constants, character-type constants and string constants are allocated in the literal constant area, the program is released after the end of the system.
5. Code Area : The memory area where the entire program code is stored. The data and code are stored separately.
C Language Memory allocation