How can you tell if the stack is growing higher in memory or lower?
Interview Answers
Anonymous
Aug 26, 2015
A Ramdump should help
it can also monitor the stackoverflow case
1
Anonymous
May 25, 2016
To determine which direction the stack is growing you compare the address of 2 adjacent local
variables. Local variables are placed onto the stack in the order they are defined (assuming they are not
in registers). You can also compare the address of the parameters passed into the function.
Anonymous
Jul 29, 2016
int main(int argc, char* argv[]) {
int a1;
int a2;
int a3;
printf("a1=%x a2=%x a3=%x\n", &a1, &a2, &a3);
return 0;
}
Output: a1=b79ce9ec a2=b79ce9e8 a3=b79ce9e4
So, the stack growing higher in memory (address decreasing)