> ## 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 Case Label

A `case` label is a specialized jump target used exclusively within the body of a `switch` statement to direct control flow. It specifies an integer constant expression that the compiler compares against the evaluated result of the `switch` statement's controlling expression. When a match occurs, execution jumps directly to the statement immediately following the label.

```c theme={"dark"}
case constant-expression: statement
```

## Technical Constraints

* **Constant Expression Requirement:** The expression following the `case` keyword must evaluate to an integer type (`int`, `char`, `enum`) at compile time. Variables, floating-point values, string literals, and function calls are strictly prohibited.
* **Uniqueness:** Every `case` label within a single `switch` block must evaluate to a unique integer value. Duplicate values will trigger a compilation error.
* **Type Promotion:** According to the C standard, integer promotions are first performed on the `switch` statement's controlling expression. Subsequently, each `case` constant expression is converted to the promoted type of the controlling expression before the comparison occurs.
* **Scope and Placement:** `case` labels have no lexical scope of their own. They must be enclosed within a `switch` statement, but C syntax permits them to be nested within other control structures inside that `switch` (a mechanic famously exploited by Duff's Device).

## Execution Mechanics

A `case` label acts purely as an entry point; it does not dictate an exit point. Once control jumps to a `case` label, execution proceeds sequentially. It will bypass subsequent `case` and `default` labels, executing their associated statements in a behavior known as "fallthrough." To terminate the execution path, an explicit jump statement (such as `break`, `return`, or `goto`) must be invoked.

```c theme={"dark"}
switch (x) {
    case 1: 
        /* Execution starts here if x == 1 */
        x = 10; 
        /* Falls through to case 2 unless a break is present */
    case 2: 
        x = 20;
        break;
}
```

## Lexical Rules Regarding Declarations

Historically in C (prior to C23), a label can only precede a statement, not a declaration. If a variable must be declared immediately following a `case` label, the execution path must be wrapped in a compound statement (a block) to satisfy the grammar rules. This compound block approach is universally valid across all versions of C.

Alternatively, an empty statement (`;`) can be placed immediately after the colon to satisfy the label requirement. However, because C89/C90 strictly requires all declarations to precede statements within a block, this empty statement workaround is only valid in C99 and later.

```c theme={"dark"}
switch (x) {
    case 1: {
        /* Universally valid (C89+): Declaration inside a compound statement */
        int y = 5; 
        x = y;
        break;
    }
    case 2: ;      
        /* Valid only in C99+: Empty statement precedes declaration */
        int z = 10;
        x = z;
        break;
}
```

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