In function `int main()':
error: invalid conversion from `char' to `char (*)[3]'
error: initializing argument 1 of `void print_board(char (*)[3])'
I tried it with a string matrix and i still get the same error. I can print the board fine in the main, but that doesn't help. I need to print it in a function.
Does anyone know what I'm doing wrong?
I think you can't pass a multidimentional array as parameter
but you could pass a pointer to char pointer (char **) and two int for the number of rows and columns
try with this code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
void print_board (char ** board, int rows, int cols)
{
//just some more code here to print the board
}
main ()
{
char board1[3][3] = {
{ 'x', ' ', ' ' },
{ ' ', 'x', ' ' },
{ ' ', ' ', 'x' }
};
print_board (board1, 3, 3);
}