cannot convert ‘bool (*)[256]’ to ‘bool**’ for argument ‘3’ to ‘bool f(unsigned int, unsigned int, bool**)’

Hi, I encountered this error in my program. I have a function

 
bool f(unsigned int, unsigned int, bool**)


and a double array

 
bool b[256][256];


But when call the function with

 
f(0,0,b)


I get the error in the title. How come? Thanks!
Because two-dimensional array is not the same as array of pointers. Extra compactness resulting in continuous memory leads to inability to do a subscript without knowing size of all dimension aside from first.

You need to declare your function as one of either:
1
2
bool f(unsigned, unsigned, bool[256][256])
bool f(unsigned, unsigned, bool[][256])
Thanks! It works!
For a little bit of insight, doing otherwise will lead to a segmentation fault. Really surprised something this can be done: http://codepad.org/rWhlSUXx

We don't know how many elements to move in the array before using the secondary dimension... I wonder what the compiler does in this case?
Topic archived. No new replies allowed.