-
function calls
I have a question regarding function calls. If function with variable(s) calls another one, which calls another one ...etc, like a chain of function calls. Where and how are the memories(of variable for instance) stored/managed for each function calls? Are they stored in a single stack automatically? thank you very much in advance.
example code:
Code:
int func1 (int x){
int a = x;
a += func2(x);
return a;
}
int func2 (int x){
int a = x;
a += func3(x);
return a;
}
int func3 (int x){
int a = x;
a += func4(x);
return a;
}
and so forth...
PS: I'm new to programming, just taking interest lately
-
All local variables will be stored on the stack.
-
Call stack - Wikipedia, the free encyclopedia
You're welcome to ask for clarification, if you can't understand any part of that page.
-
Yep, your thinking is correct that it's a 'single' stack as well.