How to paas array to function explain

Passing array to function

Passing arrays

To pass an array argument to a function, specify the name of the array without any brackets
int myArray[ 24 ];
myFunction( myArray, 24 );
Array size usually passed to function
Arrays passed call-by-reference
Name of array is address of first element
Function knows where the array is stored
Modifies original memory locations

Passing array elements

Passed by call-by-value
Pass subscripted name (i.e., myArray[ 3 ]) to function

Function prototype

void modifyArray( int b[], int arraySize );
Parameter names optional in prototype
int b[] could be written int []
int arraySize could be simply int
   

Labels: