meanings of Pointer arithmetic encyclopedia of Pointer arithmetic dictionary of Pointer arithmetic thesaurus on Pointer arithmetic books about Pointer arithmetic dreams about Pointer arithmetic
 Pointer arithmetic - Definition 

This article or section should be merged with pointer.

Pointer arithmetic is a particular arithmetic involving pointers, typical of the C programming language.

In pointer arithmetic, the unit is the size of the pointer's type. For example, adding 1 to a pointer to integer values (which typically span 4 bytes) will increment the pointer by 4. But, the end result will be in the pointer pointing right at the next element, which was probably the intended result.

Pointer arithmetic provides the programmer with a single way of dealing with different types: adding and subtracting the number of elements required instead of the actual offset in bytes. In particular, the C definition explicitly declares that the syntax a[n], which is the n-th element of the array pointed by a, is equivalent to *(a+n), which is the content of the element pointed by a+n.

While powerful, pointer arithmetic is an endless source of computer bugs. It tends to confuse programmers, forcing them into different contexts: an expression can be an ordinary arithmetic one or a pointer arithmetic one, and sometimes it is easy to mistake one for the other.

Many modern high level computer languages (for example Java) do not permit direct access to memory using addresses, so concepts of pointers and pointer arithmetic are not relevant. This is often deliberate, as many programming tasks do not require specific knowledge of where and how in computer memory data is stored.

Copyright 2008 WordIQ.com - Privacy Policy  ::  Terms of Use  :: Contact Us  :: About Us
This article is licensed under the GNU Free Documentation License. It uses material from the Wikipedia article "Pointer arithmetic".