1.
Are memory adresses a certain size?
I've seen some that have 6 characters after the 0x
and some that have 8 after the 0x
2.
A pointer like this: int *pointern
does what exactly?
Selects a location in the memory? Randomly? Or maybe like the first availible memory adress?
If I do cout<<pointern I get:0x77159e34
and a cout<<*pointern gives: -7494423 Wth?
3.
When I do: pointern = new int [5]
the adresses are 0x5f0fb0, 0x5f0fb4 etc.
What happened to the 0x77159e34?
4.
I only have one variable, the int *pointern
If I do pointern = new int[5] and then give them the values
1, 2 , 3 ,4 ,5
And then cout the adress of pointern[0] - pointern[4] and their values i get
1, 2 ,3 ,4 ,5 as expected, but if I take it one step further and cout the next adress and value, i get a very high number.
What the hell is that from?
Is it another program or something?
Or.....?
The code:
int *pointern;
pointern = new int[5];
for(int i=0; i<5; i++)
{
pointern[i] = i+1;
}
for(int i=0; i<6; i++)
{
cout <<pointern <<"\t" <<*pointern <<endl;
pointern++;
}
This will print the following on the screen:
0x3b0fb0 1 //pointern[0]
0x3b0fb4 2 //pointern[1]
0x3b0fb8 3 //pointern[2]
0x3b0fbc 4 //pointern[3]
0x3b0fc0 5 //pointern[4]
0x3b0fb4 1919381362 //the adress after pointern[4]
5.
Is it possible to get a value from a memory adress?
For example, if I have the memory adress 0x3b1cf2, can I find out the value located in that adress?
a. If it's a variable from my own program
b. If it's a adress that my program hasn't stored anything in
I'd really appreciate it if someone could answer these for me
Thanks ;/