my first integers adress is higher than second?
hi,
I made this little program to see where my two integer addresses would be located.
but then I noticed something strange..
(the code)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
int main()
{
int value = 31;
int *pointer = &value;
int secondValue = 54;
int *secondPointer = &secondValue;
cout << "First " <<pointer << endl;
cout << "Second " << secondPointer << endl;
return 0;
}
|
so basically the program creates two values and two pointers and then prints out the memory addresses...
here's what it outputs:
1 2
|
First 0x28fee4
Second 0x28fee0
|
which means that the first variable is located at:
(hexadecimal number) 4
and the second variable is located at:
(hexadecimal number) 0
but shouldn't it be the other way around?
shouldn't the first on be located at 0 ?
and the second one be located at 4?
You don't indicate what platform you ran this on.
On some platforms, including Intel x86, the stack grows "downward", so it's normal for for those addresses to be descending.
Topic archived. No new replies allowed.