Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
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".
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
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson
files and sockets come to mind also.
Not quite:Originally Posted by std10093
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.Originally Posted by c99tutorial
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Well, you are correct. I had in mind the dynamic allocation of arrays
Code - functions and small libraries I use
It’s 2014 and I still use printf() for debugging.
"Programs must be written for people to read, and only incidentally for machines to execute. " —Harold Abelson