> ## Documentation Index
> Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
> Use this file to discover all available pages before exploring further.

# C Address-of

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:**

```c theme={"dark"}
&operand
```

**Example:**

```c theme={"dark"}
int x = 10;
int *ptr = &x; /* & evaluates to the memory address of the lvalue 'x' */
```

## 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:**

```c theme={"dark"}
operand1 & operand2
```

**Example:**

```c theme={"dark"}
unsigned char a = 0x3C;  /* Binary: 0011 1100 */
unsigned char b = 0x19;  /* Binary: 0001 1001 */
unsigned char c = a & b; /* Binary: 0001 1000 (Evaluates to 0x18) */
```

## 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.

```c theme={"dark"}
/* Precedence visualization */
int val = 5;
int mask = 1;
int *ptr = &val;

/* Binary & evaluates after == due to precedence rules */
/* (ptr == &val) is evaluated first, then the binary & is applied */
int result = mask & ptr == &val; 
```

<div
  style={{ 
display: "flex", 
justifyContent: "space-between", 
alignItems: "center", 
maxWidth: "754px", 
padding: "1rem 0",
marginBottom: "24px"
}}
>
  <span style={{ fontWeight: "bold", fontSize: "1.25rem", color: "var(--tw-prose-headings)", fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" }}>Tired of Poor C Skills? Fix That With Deep Grasping!</span>

  <a
    href="https://syntblaze.com"
    target="_blank"
    style={{ 
  marginLeft: "24px",
  textDecoration: "none", 
  backgroundColor: "#007AFF",
  color: "#ffffff", 
  padding: "6px 16px", 
  borderRadius: "16px",
  fontSize: "0.9rem",
  fontWeight: "600",
  textAlign: "center",
  transition: "background-color 0.2s ease"
}}
  >
    Learn More
  </a>
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/skill-tracking.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=b9b0305c93bb501c9e767b5c76c88835" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/skill-tracking.png" />

  <img src="https://mintcdn.com/syntblazellc/23tyuOzaWS88qFlc/images/nuggets.png?fit=max&auto=format&n=23tyuOzaWS88qFlc&q=85&s=c86c80197299762989e9b882419b2109" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/nuggets.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/bite-sized-exercises.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=a65f9a38c37ff28ab73ed783c53c60e3" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/bite-sized-exercises.png" />
</div>

<div style={{ display: "flex", gap: "12px", flexWrap: "wrap", marginTop: "12px" }}>
  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/mastery-chain.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=748a1763454713e679260fbb95f154a2" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/mastery-chain.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-previews.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=242f61448ff5dd6deaaab2dccc13b507" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-previews.png" />

  <img src="https://mintcdn.com/syntblazellc/-L0ums_2lctDSZ1l/images/element-explanations.png?fit=max&auto=format&n=-L0ums_2lctDSZ1l&q=85&s=cf0fc1c31f9cd0fc26716781be05fbc9" style={{ width: "30%", minWidth: 60 }} width="621" height="1344" data-path="images/element-explanations.png" />
</div>
