Created: 2023-01-12 20:39
Status: #concept
Subject: Programming
Tags: C Function
Pass-by-Reference
Refers to the action of passing a Function argument through its Memory Address instead of Pass-By-Value.
It is required in order for the function to manipulate the argument within its Local Scope.
C Syntax
We then have to pass a Memory Address argument through the Address Operator &var
or a Pointer Variable p
into the Function call.
const Function Parameter Modifier
Prepending
const
to a Function Pointer Parameter will allow us to do Pass-by-Reference, BUT NOT LET US MODIFY THE ORIGINAL VARIABLE'S VALUE.
Adding
const
makes a data type Constant and won't change during program execution.
References
- C Programming, A Modern Approach, 2nd Edition, Chapter 11.4