Can You Tell Me What Is The Memory Layout Of A C Program?

1

1 Answers

Mohsin Hijazee Profile
Mohsin Hijazee answered
Memory layout of a program is mostly dependent on the operating system but in general, there is a data segment where all of your global/static and constant data is stored. The second are is the code are which contains the executable code itself.
The third are is the heap which is a free memory slot from which memory is allocated whenever you use malloc()/calloc() etc.
Fourth and last area is the stack. Stack is used to store your local variables and is used for passing arguments to the functions along with the return address of the instruction which is to be executed after the function call is over.

Answer Question

Anonymous