Quick question about pointers

Posted by xbonez on Stack Overflow See other posts from Stack Overflow or by xbonez
Published on 2010-05-14T02:14:54Z Indexed on 2010/05/14 2:24 UTC
Read the original article Hit count: 248

Filed under:

So, I have this code fragment:

int * iPtr ;
int * jPtr ;
int i = 5, k = 7;
iPtr = &i;
jPtr = iPtr ;

I have just started learning about pointers, and need to get some doubts cleared.

  1. is jPtr now essentially also pointing at i?
  2. I know I can change the value of i by using *iPtr, but how can I change the value of the object being pointed to by jPtr?
  3. How will changing the object being pointed to by jPtr affect the value of the object pointed to by iPtr, and i ?

© Stack Overflow or respective owner

Related posts about c++