please correct me if i am wrong, this is what i understood and duno if it's valid or not , please correct and complete what i've said :)
When you pass an address to a function, that address is actually passed by value! Because the address is passed by value, if you change the value of that address within the function, you are actually changing a temporary copy. Consequently, the original pointer address will not be changed! |
you may change the value within the copy address you got (as you will be creating a new pointer to that copy address) but you can't change the address at this pointer as all what you did was sending the address pointed by the pointer (value of pointer) and not the pointer itself
and to change what this pointer points to you need to send an address for pointer of pointer, so you can change the actual address in the first level pointer by changing the value pointed by the second level pointer
so you send pointer1 pointing to pointer2 for an ex. int imint
by passing &pointer1 you can change the value of pointer2 which is the address of imint
and you still can use pointer2 value that you pass as an argument to change the value of imint
is that right ? any other way of getting it done ? thanks in advance and forgive my ignorance
edit: i've read more and figured out how to pass a reference of a pointer but i still want to make sure that the pointer of pointer idea was almost the same as of what i know that reference are built in within pointers logic so it should be the same , am i right ? sorry i still need to make sure of what i thought of :)