Skip to main content
The & operator in C serves two distinct syntactic and semantic roles depending on its arity: as a unary operator, it functions as the address-of operator, yielding the memory address of its operand; as a binary operator, it functions as the bitwise AND operator, performing a bit-level logical AND operation between two integer operands.

Unary & (Address-of Operator)

When used with a single operand, & evaluates to a pointer to that operand. Operand Constraints: The operand must be an lvalue (an expression referring to an object that occupies an identifiable location in memory), a function designator, or an array name. The unary & operator cannot be applied to:
  • Variables explicitly declared with the register storage class.
  • Bit-fields within a struct or union.
  • Constants or literal values (excluding compound literals).
  • Expressions that do not yield an lvalue (e.g., the result of a + b).
Type Evaluation: If the operand is of type T, the expression &operand yields a result of type T* (pointer to T). Syntax:
Example:

Binary & (Bitwise AND Operator)

When used with two operands, & performs a bitwise AND operation. It compares each bit of the first operand’s binary representation to the corresponding bit of the second operand. The resulting bit is set to 1 if and only if both corresponding bits are 1; otherwise, it is set to 0. Operand Constraints: Both operands must be of an integral type (e.g., char, short, int, long, or their unsigned variants). It cannot be applied to floating-point types or pointers. Type Evaluation: Before the operation is performed, the usual arithmetic conversions are applied to both operands to bring them to a common type. The result of the expression is of this common promoted integral type. Syntax:
Example:

Precedence and Associativity

The compiler distinguishes between the two forms based on lexical context, and they occupy different levels in the C operator precedence table:
  • Unary &: Has very high precedence (Level 2, alongside other unary operators like *, ++, sizeof). It evaluates with right-to-left associativity.
  • Binary &: Has lower precedence (Level 8, which is below equality operators like == and != but above logical operators like &&). It evaluates with left-to-right associativity.
Tired of Poor C Skills? Fix That With Deep Grasping!Learn More