Methods of Parameter Passing in C
There are two ways in which we can pass the parameters to the function in C:
Parameter Passing Techniques in C
In C, there are different ways in which parameter data can be passed into and out of methods and functions. Let us assume that a function B() is called from another function A(). In this case, A is called the “caller function” and B is called the “called function or callee function”. Also, the arguments which A sends to B are called actual arguments and the parameters of B are called formal arguments.
Terminology
- Formal Parameter: A variable and its type as it appears in the prototype of the function or method.
- Actual Parameter: The variable or expression corresponding to a formal parameter that appears in the function or method call in the calling environment.
- Modes:
- IN: Passes info from caller to the callee.
- OUT: Callee writes values in the caller.
- IN/OUT: The caller tells the callee the value of the variable, which the callee may update.