> ## 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 Pointer Parameter

A pointer parameter in C is a function argument that accepts a memory address rather than a direct data value. By passing a pointer, the function receives a reference to the original variable's location in memory, enabling direct manipulation of the caller's data and avoiding the overhead of copying large data structures.

Under the hood, C strictly employs pass-by-value semantics. When a pointer is passed as a parameter, the function receives a local, independent copy of the memory address. Modifying the pointer variable itself within the function does not affect the original pointer in the calling scope. However, applying the indirection operator (`*`) to the pointer allows the function to mutate the data residing at that specific memory address.

```c theme={"dark"}
// Function declaration with a pointer parameter
void mutateData(int *ptr);

int main() {
    int target = 10;
    
    // The address-of operator (&) yields the memory address of 'target'
    mutateData(&target); 
    
    return 0;
}

void mutateData(int *ptr) {
    // Dereferencing 'ptr' accesses the memory location of 'target'
    *ptr = 20; 
}
```

## Memory Model Behavior

When a function with a pointer parameter is invoked:

1. A new stack frame is allocated for the called function.
2. The pointer parameter (e.g., `ptr`) is instantiated as a local variable within this new stack frame.
3. The value assigned to `ptr` is the raw memory address of the argument passed by the caller.
4. Any dereference operation (`*ptr`) resolves this address, crossing stack frame boundaries to read or write to the caller's original memory location.

## Const Qualifiers in Pointer Parameters

Pointer parameters frequently utilize the `const` qualifier to enforce strict memory access controls at compile-time. The placement of the `const` keyword relative to the asterisk (`*`) dictates the mutability of the pointer and the underlying data.

```c theme={"dark"}
// 1. Pointer to constant data: 
// The function can change where 'ptr' points, but cannot modify the data at that address.
void readOnlyData(const int *ptr);

// 2. Constant pointer to mutable data: 
// The function can modify the data, but 'ptr' must always point to the initial address.
void fixedPointer(int * const ptr);

// 3. Constant pointer to constant data: 
// Neither the memory address held by 'ptr' nor the underlying data can be modified.
void strictlyReadOnly(const int * const ptr);
```

## Array Decay

In C function signatures, array parameters automatically decay into pointers to their first element. The compiler treats an array declaration in a parameter list as syntactically and semantically identical to a pointer declaration. Because of this decay, the `sizeof` operator applied to an array parameter will yield the size of the pointer, not the size of the original array.

```c theme={"dark"}
// These two function signatures are entirely equivalent to the C compiler
void processBuffer(int buffer[]);
void processBuffer(int *buffer);
```

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