Pointer Arithmetic
•
Example:
•
5 element
int
array on a machine using
4
byte
int
s
–
vPtr
points to first element
v[ 0 ]
, which is at location
3000
•
vPtr = 3000
–
vPtr += 2
; sets
vPtr
to
3008
•
vPtr
points to
v[ 2 ]
•
pointer
variable
vPtr
v[0]
v[1]
v[2]
v[4]
v[3]
3000
3004
3008
3012
3016
location