integer pointer, then actually we are adding 2 to it.
For example,
int *ptr;
ptr = ptr + 2;
If ‘ptr’ holds 2000 (address), then after the execution of the second statement, ‘ptr’ gets 2002.
Subtraction works similarly.
A character pointer also works like this, except its size is different now. When we increment or
decrement a character pointer variable, its value is incremented/decremented by 1. This is because a
character occupies 1 byte in memory. Along similar lines, a float pointer variable’s value, when
incremented/decremented, increases/decreases by 4.
Do'stlaringiz bilan baham: |