Understanding nested functions


Now that we know the basic memory layout, let's examine how large computer programs are implemented. Computer programs do not contain just a single function but multiple functions. The functions call each other constantly, making the code modular and easy to understand. We know that the stack memory of a process is dedicated to storing information about a function.

Loading Image

Nested function call

Whenever a program has a function call, all the data associated with that function call, like the local variables, function parameters, return address, etc., gets stored in a stack frame structure. Data for each function call has its own stack frame, stored in LIFO order in the stack memory.

Liking the course? Check our discounted plans to continue learning.