Course Content
Programming in C
About Lesson

In C, all function arguments are passed “by value”. This means that the called function is given the values of its arguments in temporary variables rather than the originals. The called function cannot directly alter a variable in the calling function; it can only alter its private, temporary copy (Some languages support “call by reference”, where the called function can change a variable from the calling function).

Call by value is an asset as it leads to more compact programs with fewer extraneous variables, because parameters can be treated as conveniently initialised local variables in the called routine.

When necessary, it is possible to arrange a function to modify a variable in a calling routine. The caller must provide the address of the variable to be set and the called function must declare the parameter to be a pointer and access the variable indirectly through it. We’ll go over pointers in details later.

When the name of an array is used as an argument, the value passed to the function is the location or address of the beginning of the array – there is no copying of array elements. By subscripting this value, the function can access and alter any element of the array.

Scroll to Top