Pointer to pointer clarification

Because you changed the value pointed to by ipp not the value of ipp. So, ipp still points to ip1 (the value of ipp), ip1's value is now the same as ip2's value, so they both point to j.

This:

*ipp = ip2;

is the same as:

ip1 = ip2;

Forget for a second about the pointing analogy. What a pointer really contains is a memory address. The & is the "address of" operator - i.e. it returns the address in memory of an object. The * operator gives you the object a pointer refers to, i.e. given a pointer containing an address, it returns the object at that memory address. So when you do *ipp = ip2, what you are doing is *ipp get the object at the address held in ipp which is ip1 and then assign to ip1 the value stored in ip2, which is the address of j.

Simply
& --> Address of
* --> Value at

Tags:

C

Pointers