VMS Help CC, Language topics, Data Types, Pointer *Conan The Librarian (sorry for the slow response - running on an old VAX) |
A pointer in C is a variable that holds the address of another variable. Pointers are declared with the asterisk operator. For example: int i, *ip, *np; /* i IS AN INTEGER, ip AND np ARE POINTERS TO INTEGERS */ The following operations are permitted on pointers: o Assigning an address to the pointer (as in ip = &i;) o Fetching the object of the pointer (by dereferencing the pointer) with the asterisk operator (i = *ip;, which assigns the addressed integer to i) o Adding (as in ip += 5;, which makes ip point to the object that is five longwords away from the initial address in ip) o Subtracting (as in i = np - ip;, which gives the number of objects separating the objects pointed to by np and ip)
|