Pointers

So i am trying to understand pointers, and failing slightly. So hoping someone can help me clear it up.


So if i declare a pointer and an int

int* pScore
int score=500

then have
pScore=&score

Does the pScore return the address of score, and then *pScore return the value in which is stored at the address of score?
Yes.

The variable pScore now has a value and that value is the address, where the value of variable score is stored.

The dereference operator * allows us to access the pointed to variable via the pointer.

1
2
3
*pScore = 42;
 // does same as
score = 42;
Ok I think I am getting it now. Thanks :)
Topic archived. No new replies allowed.