1/7
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No study sessions yet.
Passing by Value
The function receives a copy of the argument, and changes to the parameter do not affect the original argument.
“Copy” Behavior in Passing by Value
The function works on temporary copies of the argument, not the argument itself.
Passing by Pointer/Address
A technique where the function takes a pointer parameter and the caller passes the argument’s address using &, allowing the function to modify the original argument.
Address-of Operator (&)
An operator used to supply an argument’s address (e.g., &a) when calling a function that takes a pointer.
Pointer Parameter (int *x)
A parameter type used to accept the address of an integer.
Dereference Operator (*) in Function Body
Used to access and modify the object being pointed to (e.g., *x = 456;).
Mimicking Pass-by-Reference in C
Using pointer parameters and passing addresses allows a function to modify the caller’s variables, similar to pass-by-reference behavior in other languages.
Default Argument Passing in C
By default, all arguments are passed by value (copy), so functions cannot modify argument variables unless pointers are used.