stack

How do I verify if my compiler stack is growing upward (increasing memory) or below (decreasing memory)?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

int main()
{
    int a = 10;
   //the first variable in the stack,
   //to see if the address is begger than the second var
    std::cout<<"First: "<<&a<<std::endl;

    //the second variable in the stack;
    int b = 20;
    std::cout<<"Second: "<<&b<<std::endl;
   
}
 


my rusult is:

First: 0x22ff44
Second: 0x22ff40

that's easy to the right answer!
good luck
Last edited on
There is no guarantee where a or b will allocated within a function. You probably want to compare local variables across function calls.
Topic archived. No new replies allowed.