Heya again!
This time, i've got a very simple question - perhaps the answer i more complicated though, hehe.
So i've got some degree of pointer-understanding gathered in my brain...
1 2 3
|
int var;
int * mypointer;
mypointer = &var;
|
Okay, so now mypointer stores the adress of var...
And we can edit the value of var by using:
*mypointer = 5
But one thing i have been wondering about, is setting a varibles adress.
Let's say...
1 2 3
|
int var1;
int var2;
&var1 = &var2;
|
Will this make var1's adress to be the same as var2's?
They can't share the adress, so does var2 get relocated to another adress?
Seems to me like this code compiled would make var1 want to move into var2's adress...
So what happens, does var2 have to move to another adress? Will the compiler tell var1 that he isn't allowed to move into var2's adress?
Edit: Oh, another question aswell... Am just reading through "Pointers and arrays" tutorial here, and when you want to give the adress of an array to a pointer, you don't specifically have to add the reference operator?
1 2 3
|
int * mypointer;
int myarray[5];
mypointer = myarray;
|
Is this equal to this?
1 2 3
|
int * mypointer;
int myarray[5];
mypointer = &myarray;
|
Or is the second case maybe even illegal to use? (though, it would certainly confuse me if it was)
Anyway, are those two code snippets equal?