process_arr (arr, sizeof arr); /* in this context, arr == &arr[0]
*/
Well that was sloppy. What I *meant* to say was that when an array
identifier appears in an expression, the type of the identifier is
converted from "array of T" to "pointer to T", and it's value is the
address of the first element in the array, *except* when the array
identifier is an operand to either sizeof or &, so:
sizeof arr -- type of arr == ARRSIZE-element array of int
&arr -- type of arr == ARRSIZE-element array of int
arr -- type of arr == pointer to int, value == &arr[0]
And someone else mentioned another way to pass arrays to functions; as
members of a struct type:
struct s {
int arr[10];
};
void process_arr(struct s *arg)
{
size_t i;
for (i = 0; i < sizeof arg->arr; i++)
{
/* do something interesting with arg->arr
*/
}
}
int main(void)
{
struct s foo;
process_arr (&foo);
return 0;
}