The Address-Of Operator

The unary prefix operator & yields the address of a variable.

This can be assigned to a pointer variable

For example:

int x;
double y;
int *a, *b;
double *c;

a = &x;  /* a now points to x */
b = a;   /* b now points to the same variable as a, x */
c = &y;  /* c points to y */

The pointer variable must be the appropriate type.

These assignments are hence illegal:

a = &y;  /* illegal */
c = &x;  /* illegal */

The address-of operator can only be applied to variables (and function names).

a = &42;        /* illegal */
c = &(x + 27);  /* illegal */

Index