I want to pass a 2D const array using a double pointer but I get a compiler error.
const unsigned char sizex=2;
const unsigned char sizey=5;
const unsigned char arr[sizex][sizey] ={
{1,2,3,4,5},
{6,7,8,9,10}};
void foo (const unsigned char **a, const unsigned char x, const unsigned char y) {
int i,j;
for(i=0;i<x;i++) {
for(j=0;j<y;j++) {
Serial.println(a[i][j]);
}
}
}
void main() {
foo(arr,sizex,sizey);
}
Error
cannot convert 'const unsigned char (*)[5]' to 'const unsigned char**' for argument '1' to 'void foo(const unsigned char**, unsigned char, unsigned char)'
void foo (const unsigned char a,[][5] const unsigned char x, const unsigned char y)
works, but I don't want to hard code [5] into the code.
Any suggestions what to do to fix this?