Function Prototypes & Call-by-Value Semantics
Why C is strictly pass-by-value and how pointers simulate reference
In C, function arguments are copied by value. The called function receives an isolated local copy on its stack frame, meaning modifying the parameter inside the function does not change the caller's variable.
pass_by_value.c
// Forward Prototype Declaration: void swap_failed(int a, int b); void swap_correct(int *a, int *b); int main(void) { int x = 10, y = 20; swap_failed(x, y); // DOES NOT SWAP: x and y remain 10 and 20 swap_correct(&x, &y); // SWAPS: Passes memory addresses so function can mutate RAM return 0; }