pass an array into a function?

Feb 23, 2014 at 3:24pm
I can pass a single dimension array into a function just fine, but I now want to know how to pass a 2D array into a function. For some reason I can't figure this one out.

Thanks for any help.
Feb 23, 2014 at 3:35pm
You need to write the length of every dimension except the first (which you can leave blank if you so choose).

So it would have to be something like
1
2
3
4
5
6
7
8
const int ROWS = 5;
const int COLUMNS = 6;

void doStuff(int array[][COLUMNS]);
// or
void doStuff2(int array[ROWS][COLUMNS]);
// but this one would not work:
//void doStuff3(int array[][]); 
Feb 23, 2014 at 3:37pm
laughing... guess which method I was trying to use. :P

Thank you very much.
Topic archived. No new replies allowed.