0

I'm having a tough time trying to make a bit of code work. I'm trying to an array that's declared as so:

char house_matrix_floor0[38][38+1] = { ... };

In between the brackets I only have strings to compose the matriz I want. The problem comes when I try to pass this matriz to a method that expects a char**, giving me this error:

argument of type "char (*)[39]" is incompatible with parameter of type "char **"

I bet this is a common problem, but i cant seem to find a solution and couldn't find an answer on the web.

Thank you for the attention and hope you can help.

InsaniTea
  • 11
  • 4
  • Also see: http://stackoverflow.com/questions/14183546/why-does-int-decay-into-int-but-not-int – NathanOliver Dec 14 '15 at 19:16
  • 2
    Go to the whiteboard and write 100 times "An array is not a pointer." – Pete Becker Dec 14 '15 at 19:33
  • @NathanOliver Thank you very mutch. – InsaniTea Dec 14 '15 at 19:51
  • @PeteBecker I really should. I'm kind of new to C++ and do not really understand the concept of a pointer as was shown, but i will read the links NathanOliver gave to not make the same mistake. – InsaniTea Dec 14 '15 at 19:53
  • The key notion is that the **name** of an array can decay into a pointer to the first element of that array, which is why you can pass an array to a function that expects a pointer. So `house_matrix_floor0` decays into a pointer to array of 38+1 elements, which is why the compiler talks about `char (*)[39]`. But that's not the name of an array, so it does not decay into a pointer to pointer. – Pete Becker Dec 14 '15 at 20:47

0 Answers0