Hello , I have the following code :
int a = 2; int *ptr = &a; int *second = &a + 1; printf("\n ptr = %p\n", ptr); printf("\n second = %p\n", second);
which just prints the address of pointers and the address of second is 4bytes next the ptr.
ptr = 0x7fffc26238b4 second = 0x7fffc26238b8
Ok until here.
If I add to the above code :
int *Newptr; Newptr = second +1; printf("\n New ptr = %p\n", Newptr);
then I am getting:
ptr = 0x7fff4086945c second = 0x7fff40869460 New ptr = 0x7fff40869464
The ptr now has different address now.The second isn't being increased by 4 bytes from the ptr.Why?
Also, when do we use :
Newptr = second +1;
When we want the Newptr to point to next memory address from second?But why?