Your Ad Here

Saturday, August 30, 2008

The & and * Pointer Operators

A pointer is the memory address of an object. A pointer variable is a variable that is specifically
declared to hold a pointer to an object of its specified type. Pointers are one of C's most powerful
features, and they are used for a wide variety of purposes. For example, they can provide a fast
means of referencing array elements. They allow
Page 54
functions to modify their calling parameters. They support linked lists, binary trees, and other
dynamic data structures. Chapter 5 is devoted exclusively to pointers. This chapter briefly covers the
two operators that are used to manipulate pointers.
The first pointer operator is &, a unary operator that returns the memory address of its operand.
(Remember, a unary operator requires only one operand.) For example,
m = &count;
places into m the memory address of the variable count. This address is the computer's internal
location of the variable. It has nothing to do with the value of count . You can think of & as meaning
''the address of." Therefore, the preceding assignment statement means "m receives the address of
count."

No comments: