Hello, im trying to make a command prompt based battle ships game, with a little AI in placing the ships. I am only up to drawing the game board and i am already stuck. here is my current code.
Code:
 #include  <iostream>

using namespace std;

int main()
{
    int d1;
    int d2;
    int gameboard[d1][d2];

    {
        cout<< "enter in columns:";
        cin>> d1;
        cin.ignore();
        cout<< "enter in rows:";
        cin>> d2;
        cin.ignore();

        {for (int x = 0; x < d1; x++)
        {for (int y = 0; y < d2; y++)
            {gameboard[x][y] = 0;}}}   // setting all elements in the array to 0

        gameboard[2][2] = 1; // changing 2 of the elements to 1 just too see what happens
        gameboard[3][3] = 1;

        {for (int x = 0; x < d1; x++)
        {for (int y = 0; y < d2; y++){
        cout<< gameboard[x][y] << " "; // shows values in all the arrays elements.

}
            cout<< "\n";}
        }

    }
cin.get();
}
when i compile and run this code it always seems to set my manually asigned array elements to the whole column. instead of the one element. is there any reason for this? or way around this to make it work properly? as i will be using this little bit later to make it randomize positions of the ships. thanks in advance.