TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
& 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
registerstorage class. - Bit-fields within a
structorunion. - Constants or literal values (excluding compound literals).
- Expressions that do not yield an lvalue (e.g., the result of
a + b).
T, the expression &operand yields a result of type T* (pointer to T).
Syntax:
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:
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.
Master C with Deep Grasping Methodology!Learn More





