Skip to content
UPEEC

Pass by Value

C always copies argument values into parameters.

Beginner
Comments 0

To let a function change a caller's variable, pass its address: void inc(int *x) { (*x)++; }. Pass large structs by const pointer to avoid copying.

Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.

Discussion (0)

Sign in or join free to ask questions and discuss this topic.