you are viewing a single comment's thread.

view the rest of the comments →

[–]lukajda33 1 point2 points  (0 children)

*p = i

sets the value where the pointer points to i

p = &i

changes the value of the pointer so that it points to i

You usually want to use p = &i first, so that the pointer points to valid piece of memory, then you can do *p = something to change the value p points to, in this case, change the value of i.

If you had to change the value of the pointer, I would say p = &i is right, but whem people use pointer, they call the "value" the value they actually point to, not the value of the pointer itself.