int i1;
int i2;
int *ptr1;
int *ptr2;
i1 = 1;
i2 = 2;
ptr1 = &i1;//ptr1 points to address 0x1000
ptr2 = ptr1;//ptr2 takes address of ptr1 and so ptr2 points to address 0x1000
*ptr1 = 3;//value of i1(to which ptr1 pointed becomes 3
i2 = *ptr2;//as i1=3,*ptr2=*ptr1=3,so i2 becomes 3
No comments:
Post a Comment