Compiler errors:
(In main)
Line 9:cannot convert char (*)[3] to char* for argument 1 to void showboard(char*, int, int)
(in showBoard)
Lines 16, 17, 21, 22, 26, 27:invalid types char[int] for array subscript
I don't understand these errors. I am trying to make a tic tac toe game, I have to initialize the board with '*'s. Right now I am merely trying to display the board with the '*'s. I have searched the forums and although there are a lot of tic tac toe threads none apply to me. Any help would be greatly appreciated, thanks!
void showBoard(char[], int, int);
int main() {
const int row = 3;
const int col = 3;
char game[row][col] = {{ '*', '*', '*'}, { '*', '*', '*'}, { '*', '*', '*'}};
showBoard(game, row, col);
return 0;
}
void showBoard(char game[], int row, int col) {
cout << setw(5) << "1" << setw(6) << "2" << setw(6) << "\n"
<< setw(8) << "|" << setw(6) << "|" << "\n"
<< "A" << setw(3) << game[0][0] << setw(3) << "|" << setw(3) << game[0][1]
<< setw(3) << "|" << setw(3) << game[0][2] << "\n"
<< setw(8) << "|" << setw(6) << "|" << "\n"
<< " ------------------------------------\n"
<< setw(8) << "|" << setw(6) << "|" << "\n"
<< "B" << setw(3) << game[1][0] << setw(3) << "|" << setw(3) << game[1][1]
<< setw(3) << "|" << setw(3) << game[1][2] << "\n"
<< setw(8) << "|" << setw(6) << "|" << "\n"
<< " ------------------------------------\n"
<< setw(8) << "|" << setw(6) << "|" << "\n"
<< "C" << setw(3) << game[2][0] << setw(3) << "|" << setw(3) << game[2][1]
<< setw(3) << "|" << setw(3) << game[2][2] << "\n"
<< setw(8) << "|" << setw(6) << "|" << "\n"
}