Arrays do behave a bit strangely when it comes to passing them to
a function.
Recall that in C, arguments are usually passed to a function by
value. That is, the argument is copied into a special area of memory
where the function can access and play with it.
On the other hand, arrays are generally big things, and it isn't
smart to copy big things -- it takes a long time. So in C, arrays
are passed to functions by reference. That is, only the memory
address of the array is passed to the function. This allows the
function to play with the array, but it has the side affect of making
all changes the function makes on the array permanent (i.e., the
changes don't go away at the end of the function).
Here's an example:
float average( float v[], int vsize )
{
float a;
a = 0.0;
for ( i = 0; i < vsize; i++ )
{
a += v[i];
}
return a / (float) vsize;
}
int main()
{
float testScores[50];
printf( "%f", average( testScores, 50 ) );
}