Passing a pointer to a function
Allowing a function to modify an external variable.
Syntax
void name(int *p) { *p = ...; }Description
You enable a function to modify the original variable by passing its address (passing by reference).
Example
Loading editor…
Expected output
10
When to use?
Returning multiple values from a function, passing large data without copying.