The address-of operator (&) gives the address of its operand. The operand of the address-of operator can be either a function designator or an l-value that designates an object that is not a bit field and is not declared with the register storage-class specifier.
The address-of operator can only be applied to variables with fundamental, structure, class, or union types that are declared at the file-scope level, or to subscripted array references. In these expressions, a constant expression that does not include the address-of operator can be added to or subtracted from the address expression.
For related information, see Indirection Operator.
Example
In the following example, the address-of-operator (&) takes the address of the third element of the nArray
and stores the result in the pointer variable pPtr
.
// Example of the address-of operator
int *pPtr;
int nArray[20];
pPtr = &nArray[2];