Game Board

Hello all.

I need help putting numbers in each square for my game board. I'm working on Tic-Tac-Toe.

I have the 2D array but I do not know how to put :

'0', '1', '2'
'3', '4', '5'
'6', '7', '8'

so the user could select which square to put their move in.

Thank you!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{
    char box1('1');
    char box2('2');
    char box3('3');
    char box4('4');
    char box5('5');
    char box6('6');
    char box7('7');
    char box8('8');
    char box9('9');
  
   
    cout << box1 << "|" << box2 << "|" << box3 << endl;
    cout << "-----" << endl;
    cout << box4 << "|" << box5 << "|" << box6 << endl;
    cout << "-----" << endl;
    cout << box7 << "|" << box8 << "|" << box9 << endl;

here enjoy
@moot1, He said he already has a 2D array for his board, so why would he create 9 new variables? That's just a waste and not efficient. ccPac014, if you already have an array (I would recommend making it a 1D array, but thats just me and not really relevant) all you have to do is change each element when need be. For example:
Let's say you have array of char with elements 1-9. You're gonna have a board displayed like you'd imagine, if the user says "Hey I want piece 6", then all you have to do is change the 5th element (index 5 would be number 6), to that players piece, either X or O, then reprint the board
Topic archived. No new replies allowed.