1. Originally Posted by std10093
Code:
```int foo(int array[n])
{
}```
Not, in this case, unless `n' is a compile-time constant (or a macro, that somehow expands to a compile-time constant).

2. Originally Posted by c99tutorial
If you have a three dimensional array declared as `double A[x][y][z]' is it clearer to address an arbitrary element with indices a, b, c as

A[a][b][c] = foo;

or

*(((A+a*x*y)+b*x)+c) = foo;

? Especially when there are more than two dimensions, the bottom form becomes tedious and error prone.

Creating a function that operates on the array A will always require 4 parameters no matter if you use the pointer notation or the array notation: you need to pass one parameter representing the array A, and you need to pass three integer parameters representing the maximum bound of each dimension.

In other words, your choices for a function bar are pretty much just these two:

void bar1(int x, int y, int z, double *A);

void bar2(int x, int y, int z, double A[x][y][z]);
Wrong. You can not pass *A.

You pass the array as I said and you handle it normally (of course not as you say...)

3. Originally Posted by std10093
You pass the array as I said and you handle it normally (of course not as you say...)
No. Your example only considers single-dimensional arrays. With an n-dimensional array passed as input into a function, the compiler needs to "know" about the the size of the highest n-1 dimensions of the array. In addition, the programmer needs to know the size of the lowest dimension of the array as well as where the array begins in memory. So in total, you must design your function to accept n+1 parameters. This fact is true independent of whether you use the C99 syntax or C89 syntax. Using the C99 syntax simply lets you use indices inside the function in a natural mathematical way, i.e. "in the normal way".

4. Yes is the answer. When you want to pass a n dimensional array you pass n stars as pointers and n dimensions. So simple.

Also, I suppose you understood your mistake before... I guess actually it won't even compile. Tip : Compile the code before you post it

Enough said and this thread is solved.

Bye

5. files and sockets come to mind also.

6. Originally Posted by std10093
When you want to pass a n dimensional array you pass n stars as pointers and n dimensions. So simple.
Not quite:
Originally Posted by c99tutorial
With an n-dimensional array passed as input into a function, the compiler needs to "know" about the the size of the highest n-1 dimensions of the array.
That is, if you pass an array of arrays as an argument, it is converted to a pointer to an array, not a pointer to a pointer.

7. Well, you are correct. I had in mind the dynamic allocation of arrays