The * and & Operators
The * and & Operators

Here are some definitions for you:

* == "star operator" == dereference operator
You have seen this before in the declaration of a pointer but this * and that * are not the same *. By using the derefernce operator, you can access the value that pointer is pointing to.

& == "address of operator" == ampersand
To access the address in memory where a variable, you need to use the address of operator. By placing an ampersand in front of a variableName, the memory address of that variable is returned.

Examples: aPtr = &a; /* aPtr now holds the address of the variable a */ b = *bPtr; /* b is assigned the value to which bPtr is pointing */ G(&c); /* the address of c is being passed to the function G */ c = *b + 7; /* c is assign the value that b is pointing to plus 7 */ Practice using and read these. They are very common and you will be seeing them again.


Main Page
Last Modified 10 November 2000