Issue passing 2-D array into a function

I'm having issues passing a 2-D arraying a function. I get an invalid operands to binary expression .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
  #include <iostream>

using namespace std;

void check(char board[][3], int ROWS){
    
}

int main() {
    int Player1 = 1;
    int Player2 = 2;
    const int ROWS = 3;
    const int COLS = 3;
    char board[ROWS][COLS] = {{'x','o','x'}, {'x','x','x'}, {'o','x','o'}};
    
    cout << "_____________\n";
    cout << "| " << board[0][0] << " | " << board[0][1] << " | " << board[0][2] << " |\n";
    cout << "|___|___|___|\n";
    cout << "| " << board[1][0] << " | " << board[1][1] << " | " << board[1][2] << " |\n";
    cout << "|___|___|___|\n";
    cout << "| " << board[2][0] << " | " << board[2][1] << " | " << board[2][2] << " |\n";
    cout << "|___|___|___|\n";
    
    
   cout<<check(board, 3)<<endl;
    
    return 0;
}

cout<<check(board, 3)<<endl;

check(board,3) is a function call. It returns void (i.e. nothing), so you're trying to pass void to cout using the operator <<.

That makes no sense.
Last edited on
Topic archived. No new replies allowed.