Empty Output in tictactoe program

In my tictactoe program, numbers are inputted symbolizing the moves
1|2|3
4|5|6
7|8|9

3 in a row wins. However, if I attempt to output the array of "X" and "O" from the input, nothing is outputted.

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <cmath>
using namespace std;

int main()
{    int games, xmoves[5], omoves[4];
    cin>>games;
    for (int i=0; i<games; i++)
    { int a, b=0;
    char tactoe[3][3];
       for (int moves=0; moves<9; moves++)
       {
           if (moves % 2 ==0)
           {cin>>xmoves[a];
           switch(xmoves[a])
           {case 1:
              tactoe[0][0] = 'X';
              case 2:
              tactoe[0][1] = 'X';
              case 3:
              tactoe[0][2] = 'X';
              case 4:
              tactoe[1][0] = 'X';
              case 5:
              tactoe[1][1] = 'X';
              case 6:
              tactoe[1][2] = 'X';
              case 7:
              tactoe[2][0]='X';
              case 8:
              tactoe[2][1] = 'X';
              case 9:
              tactoe[2][2] = 'X';
               }
           a++;}
           
           else
           {cin>>omoves[b];
           switch(omoves[b])
           {case 1:
              tactoe[0][0] = 'O';
              case 2:
              tactoe[0][1] = 'O';
              case 3:
              tactoe[0][2] = 'O';
              case 4:
              tactoe[1][0] = 'O';
              case 5:
              tactoe[1][1] = 'O';
              case 6:
              tactoe[1][2] = 'O';
              case 7:
              tactoe[2][0]= 'O';
              case 8:
              tactoe[2][1] = 'O';
              case 9:
              tactoe[2][2] = 'O';
               }
              b++;}
       }
       cout<<tactoe;
    }
} 


Input:14
2 9 4 5 7 3 1 8 6
7 6 3 2 9 5 4 8 1
2 9 6 7 1 3 4 8 5
3 7 9 5 4 8 6 1 2
2 1 3 4 5 7 9 6 8
2 4 1 3 9 7 6 5 8
1 5 7 3 2 8 9 4 6
4 1 9 2 8 3 5 6 7
7 4 5 9 3 8 2 6 1
1 8 7 5 2 4 3 9 6
9 6 5 2 3 1 4 7 8
9 5 3 2 6 7 8 4 1
6 7 8 3 2 4 5 9 1
1 6 5 9 7 3 8 4 2

Output:
[absolutely nothing]
Last edited on
closed account (D80DSL3A)
You forgot to assign a an initial value. Line 46 int a, b =0;
The only place I see numbers output is on lines 55 and 64 {cout<<a+b+1<<" "; break;}
This may be the whole issue.

Why not say it a tic-tac-toe game? Knowing what the program is trying to do helps with code reading and interpretation, especially with the unconventional code formatting in the main().
The code looks all crushed together.
Last edited on
sorry about that.
Welp, I changed my strategy to what I think is a more efficient one. I used a two-dimensional array instead. It's still a work in progress. I'll post it when I'm done.
Topic archived. No new replies allowed.