Question on Entering Game Board into 2D array

Making a Game for a school project and Im using a 2D array to make the gameboard. Well in the begginning of the game the user has to input what the current game board looks like. I have it so the user is entering data and the data is being entered into the array,but the newline character at the end of each input is missing it up,here is the portion of code Im working with atm.

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
      char board;
      int a = 6,i = 6;
      cout << " Please enter what the board looks like: "<<endl;
      cin.get(board);

      while(cin)
      {
          cout<<"board is ="<<board<<"and going into position"<<a<<i<<endl;
          /*
          if(board == ' ')
          gameBoard[a][i] = ' ';
          else
          gameBoard[a][i] = board;
          */
          if(i>0)
          {
           i--;
          }
          else
          {
           a--;
           i = 6;
          }
          cin.get(board);
      }

if you need the entire code,just let me know
I just did this game just a week ago and I didn't have code looking anything like this. Post all of your code please. I don't think you're making the board correctly.

Here is my section of code:

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
29
30
31
class Gameboard
{
    private:
        Cell[9];
    public:
        void Print();
        Gameboard();
        ~Gameboard(){};
};

Gameboard::Gameboard()
{
    for (int X = 0; X < 9; X++) Cell[X] = '\0';
}

void Print()
{
    // Code that prints out the board.
}

// Player 1 Move

// Player 2 Move

// Win Check

main()
{
    // Code for main() here.
    system("pause");
}


That is just an example. If you post your entire code I'll see what's going on.
Last edited on
Topic archived. No new replies allowed.