How to properly pass through multidimensional arrays? [closed]

  arrays, c++, matrix, parameter-passing, pointers
int main()
{
//In battleshipplacement() I place a battleship on a 8*8 grid
    int Grid = battleshipplacement();
    ShowGrid(Grid);
    return 0;
}
void ShowGrid(int Grid)
{
    cout << '|';
    for (int y = 0; y < 8; y++) {
        for (int x = 0; x < 8; x++) {
            cout << ' ' << Grid[x][y] << ' ';
            if ((x + 1) % 8 == 0) {
                cout << '|' << endl << '|';
            }
        }
    }
    cout << 'r';
}

On line 13 I get the error "Severity Code Description Project File Line Suppression State
Error (active) E0142 expression must have pointer-to-object type Testing battleship placement C:UsersUserOneDriveUserC++Learning C++Testing battleship placementSource.cpp 54". When trying to fix this by adding int*/int** to ShowGrid() I get a slew of more issues so I’m wondering how does one do this
EDIT:Added battleshipplacement()

int battleshipplacement()
{
    srand(time(NULL));
    int Grid[8][8] = {0};
    int VerticalHorizontal = rand() % 2;

    int BattleShipPlaceX = rand() % 5;
    int BattleShipPlaceY = rand() % 5;

    if (VerticalHorizontal == 0)
    {
        Grid[BattleShipPlaceX][BattleShipPlaceY] = 1;
        Grid[BattleShipPlaceX + 1][BattleShipPlaceY] = 1;
        Grid[BattleShipPlaceX + 2][BattleShipPlaceY] = 1;
    
    }
    else 
    {
        Grid[BattleShipPlaceX][BattleShipPlaceY] = 1;
        Grid[BattleShipPlaceX][BattleShipPlaceY + 1] = 1;
        Grid[BattleShipPlaceX][BattleShipPlaceY + 2] = 1;
    }
    return **Grid;
}

Source: Windows Questions C++

LEAVE A COMMENT