One of the
nice things about a
low level language.
Adding or
subtracting to a
memory address (
technically, you could
divide or
multiply, but that would be
useless and would more than likely
segment)
This is usually - scratch that, always - done with some sort of array. For instance, you can loop through an entire zero-terminated array (perfect example: a C string) with just while(*ptr++);. You can even copy a string with just while( *dest++ = *cpy++ );, and in the process totally confuse people.
Let's say you have a pointer, ptr, to an array. So ptr+1 is the memory one unit after ptr, or &ptr[1]. Similarly, ptr-1 is one unit before ptr. Subtraction is also nice if you, say, want to figure out how far an array element is from its start (example: the return of strstr subtracted from its first arg == position in string)
In
C,
pointer arithmetic is done in
sizeof(*ptr) units. Thus, you cannot do
arithmetic with a
void pointer, as
sizeof(void) == 0.