Passing Array to Function

An array can be passed into a function either as:

  • pointer
  • sized array
  • unsized array

The array identifier and its size are sent as arguments to the function on line 22:

avgGrade = avgFunc( myArray, 7 ) ;


The function receives these as a pointer to the array and its size, on line 3:

double avgFunc(int *passedArray, int passedSize)


The first argument in the function's interface could alternatively have been:

  • int *passedArray
  • int passedArray[7]
  • int passedArray[ ]

Leave a Reply