Engineering Science 1036A/B Lecture 15: Arrays: Passing Arrays to Functions
The name of the array and size is passed to the function
•
How to declare and invoke a function getting an array
○
Pass by Reference
Starting address of the array is passed to the formal parameter
Called pass by reference: only the name of the array is passed
○
•
The parameter inside the function references to the same array that is passed
to the function
•
No new array is created in this process
The new array name becomes the alias of the old array name
○
•
When passing an array to a function, the size should also be passed through a
another argument
•
A function definition header may use square brackets with or without indicating
the size of the array inside the brackets
•
•
•
Passing Arrays to Functions