> ## 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 Pre-Decrement

The `--` (decrement) operator is a unary arithmetic operator that decreases the value of its operand by one. It requires a modifiable lvalue of a scalar type (integer, floating-point, or pointer) as its operand.

The operator exists in two forms, which differ strictly in their value computation relative to the side effect of modifying the operand.

## Prefix Decrement (`--x`)

In the prefix form, the operator is placed before the operand.

* **Side effect:** The value of the operand is decremented by 1.
* **Value computation:** The expression evaluates to the **new, decremented** value of the operand.

```c theme={"dark"}
int x = 10;
int y = --x; 
/* 
   1. x is decremented to 9.
   2. The expression '--x' evaluates to 9.
   3. y is assigned 9.
*/
```

## Postfix Decrement (`x--`)

In the postfix form, the operator is placed after the operand.

* **Side effect:** The value of the operand is decremented by 1.
* **Value computation:** The expression evaluates to the **original, un-decremented** value of the operand.

```c theme={"dark"}
int a = 10;
int b = a--; 
/* 
   1. The expression 'a--' evaluates to the original value, 10.
   2. a is decremented to 9.
   3. b is assigned 10.
*/
```

## Technical Constraints and Behavior

**Pointer Arithmetic**
When applied to a pointer, the `--` operator does not simply subtract one byte from the memory address. Instead, it decrements the address by the size of the pointed-to type (`sizeof(type)`).

```c theme={"dark"}
int *ptr = (int *)0x1004;
ptr--; // If sizeof(int) is 4, ptr becomes 0x1000, not 0x1003.
```

**Rvalue Result**
In C, the result of both the prefix and postfix decrement operators is an **rvalue** (a temporary value), not an lvalue. Consequently, you cannot chain decrement operators or assign a value to the result of a decrement operation.

```c theme={"dark"}
int x = 5;
--(--x); // Compilation error: lvalue required as decrement operand
(--x) = 10; // Compilation error: lvalue required as left operand of assignment
```

**Sequence Points and Undefined Behavior**
The C standard dictates that the side effect of updating the operand's value must be complete before the next sequence point. Modifying the same scalar object more than once between sequence points, or modifying it and reading its value for a purpose other than determining the value to be stored, invokes **Undefined Behavior (UB)**.

```c theme={"dark"}
int i = 5;
i = i--;       // Undefined Behavior: modifying 'i' twice without an intervening sequence point
int arr[5];
arr[i] = i--;  // Undefined Behavior: reading and modifying 'i' unsequenced
```

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