- by nn
Hi,
I'm writing a simple test program to pass multidimensional arrays. I've been struggling to get the signature of the callee function.
void p(int (*s)[100], int n) { ... }
In the code I have:
int s1[10][100], s2[10][1000]; p(s1, 100);
This code appears to work, but it's not what I intended. I want to the function p to be oblivious whether the range of values is 100 or 1000, but it should know there are 10 pointers.
I tried as a first attempt:
void p(int (*s)[10], int n) // n = # elements in the range of the array
and also:
void p(int **s, int n) // n = # of elements in the range of the array
But to no avail can I seem to get this correct. I don't want to hardcode the 100 or 1000, but instead pass it in, but there will always be 10 arrays.
Obviously, I want to avoid having to declare the function:
void p(int *s1, int *s2, int *s3, ..., int *s10, int n)
FYI, I'm looking at the answers to a similar question but still confused.