Array as a whole can be used as function parameter.

for example: here we design a function to do mergesort. The prototype is as follows, 

 

void MergeSort(int B[], int iBegin, int iEnd, int A[]);

Note; int B[] means B[] is an integer array. int A[] means A[] is an integer array

while invoking function, we use following format:

 

MergeSort(B, 0, SIZE, A);

here, only array names A and B are used, instead of A[] or B[].

 

void MergeSort(int B[], int iBegin, int iEnd, int A[])

{

    …

}

Please note: array name is address, base address of the array. Hence, we can manupilate the array elements in the function.

You have no rights to post comments