1 2 3 4 5 6 7 8 9 10

Parameter Passing

*

All parameter passing in C is by value, that is, when a function is called the parameter values from the calling function are copied into temporary storagein the called function--all modifications to the parameter values occur in this temporary storage;the original values in the calling function are not changed

This means that you cannot return a result directly through a parameter. The only way to export a result with a parameter is to do so indirectly through a pointer to the location where the result will be stored

Remember arrays are built with pointers, so if you pass an array address (not an array element) to a function, you can modify the elements in the array and these changes will be seen outside of the function

*

*

void initialize (int x) {

we can do anything we like to x inside this function. The calling function won't see any of these changes. It provides only the initial value of x
x = 5;

}

but consider ::::::::

January22, 1999

Page 5

copyright UoA