switches with cout. Why doesn't it work?

I'm making a tic tac toe game for a homework question.
And i'm getting confused on why this isn't working(it is the first time i've tried to do something as big as this(for me))

I'm getting the error "expected expression". So I know i'm supposed to be including an ";" or some brackets somewhere. I've looked over it countless times and I can't see it. often i'll come back a few hours later and see it. but it hasn't worked this time

the error is on line 7.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void TTTBoard()
{
    cout << "T1 T2 T3" << endl;
    cout << "M1 M2 M3" << endl;
    cout << "B1 B2 B3" << endl << endl;
    
    cout << switch(T1)
    {
case: T1_S
    break
case: T1_O
    break
case: T1_X
    break;
    }
}



This is still a wip. i've just started

FULL 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
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <iostream>
#include <string>
using namespace std;

void clearScreen();
void TTTBoard();
void Menu();
void userInput();
bool winVerify(string val1, string val2, string val3);

enum ET1{
    T1_X = 1, T1_O = 2, T1_S = 0
};
enum ET2{
    T2_X = 1, T2_O = 2, T2_S = 0
};
enum ET3{
    T3_X = 1, T3_O = 2, T3_S = 0
};
enum EM1{
    M1_X = 1, M1_O = 2, M1_S = 0
};
enum EM2{
    M2_X = 1, M2_O = 2, M2_S = 0
};
enum EM3{
    M3_X = 1, M3_O = 2, M3_S = 0
};
enum EB1{
    B1_X = 1, B1_O = 2, B1_S = 0
};
enum EB2{
    B2_X = 1, B2_O = 2, B2_S = 0
};
enum EB3{
    B3_X = 1, B3_O = 2, B3_S = 0
};


ET1 T1 = T1_S;
ET2 T2 = T2_S;
ET3 T3 = T3_S;
EM1 M1 = M1_S;
EM2 M2 = M2_S;
EM3 M3 = M3_S;
EB1 B1 = B1_S;
EB2 B2 = B2_S;
EB3 B3 = B3_S;

void TTTBoard()
{
    cout << "T1 T2 T3" << endl;
    cout << "M1 M2 M3" << endl;
    cout << "B1 B2 B3" << endl << endl;
    
    cout << switch(T1)
    {
case: T1_S
    break
case: T1_O
    break
case: T1_X
    break;
    }
}

void clearSceen()
{
    for (int loop = 100; (!(loop == 0)); loop--)
    {
        cout << endl;
    }
}

void Menu()
{
    cout << "Welcome to Radar's Tic Tac Toe board" << endl;
    cout << "Key:" << endl;
    cout << "H = Spare" << endl;
    cout << "X = Player one's spot" << endl;
    cout << "O = Player two's spot" << endl << endl;
    return;
}

int main()
{
    while (1)
    {
        //Menu();
        //TTTBoard();
       //userInput();
        //winVerify();
    }
    
}
1
2
3
4
5
6
case: T1_S
    break
case: T1_O
    break
case: T1_X
    break;


Just edited it a bit. i'm silly. but the error is still there.

up to date code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
void TTTBoard()
{
    cout << "T1 T2 T3" << endl;
    cout << "M1 M2 M3" << endl;
    cout << "B1 B2 B3" << endl << endl;
    
    cout << switch(T1)
    {
case T1_S:
    break
case T1_O:
    break
case T1_X:
    break
    };
}
You need a semi colon after each break
Switch is a statement. It does not return anything. It is standalone block of code.
cheers.
I've rewritten it to
1
2
3
4
5
6
7
8
9
10
11
12
switch (T1)
    {
        case T1_X:
            cout << "X ";
            break;
        case T1_O:
            cout << "O ";
            break;
        case T1_S:
            cout << "H ";
            break;
    }

opinions?
One thing that really stands out to me is that you have an enumeration for every square of the board, when really you only need one enumeration to represent the values a square can have. If you do that, you can then make all the squares of that single enumeration type.
Topic archived. No new replies allowed.