Next: Function Prototyping Up: Functions Previous: void functions

Functions and Arrays

Single dimensional arrays can be passed to functions as follows:-

float findaverage(int size, float list[])

Here the declaration float list[] tells C that list is an array of float. Note we do not specify the dimension of the array when it is a parameter of a function.

Multi-dimensional arrays can be passed to functions as follows:

void printtable(int xsize, int ysize, float table[][5])

Here float table[][5] tells C that table is an array of dimension Nx5 of float. Note we must specify the second (and subsequent) dimension of the array BUT not the first dimension.


drago@scri.fsu.edu
Jan. 1997