Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
You can perform arithmetic on pointers, but it's different from regular math. Incrementing a pointer moves it by the SIZE of the data type it points to.
ptr++Moves to the next memory location of the type
ptr--Moves to the previous memory location of the type
ptr + nMoves n elements forward
ptr1 - ptr2Number of elements between two pointers
If an int is 4 bytes and ptr is at 1000:
ptr + 1; // Address becomes 1004 (not 1001!)You cannot multiply or divide pointers. You also cannot add two pointers together (that address wouldn't mean anything).