please help :)!!

Im seriously new to C++ and any programming language. I do software design as a subject at school. I have an assignment where I have to write a tic tac toe game in C++. I didnt want to copy anyone elses game and I tried to start from scratch with the teachers help. However I've derived a code, I know my syntax is abit out of wack and it may not be the most logical code, but that is why I need help. Also getting the variables right. The compiler we have to use is codeblocks. Although from this I have recieved the errors I recieved were:

line: 17 error: expected ',' or ';' before '=' token
line: 20 error: two or more data types in decleration of 'Grid'
line: 34 error: expected initializer before 'int'
line: 39 error: expected ',' or ';' before 'bool'

The deadline is really soon, so im really eager to finish this this. Your help would be awesome!. Thanks alot, Maryann.

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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
//SDD 2012
//26/8/12 - 27/8/12
//Tic tac toe assignment

#include <iostream>
#include <string>

using namespace std;

//allowing players to be identified by their own name
string playerone ();
string playertwo ();

//variables for the spaces in the game board
char G = 1to9;
char Grid (G) = G;

//tic tac toe board for game play
void char Grid (G)
{
    cout << "_____________________________________________________"
    cout << "|" + Grid (1) + "|" + Grid (2) + "|" + Grid (3) + "|"
    cout << "_____________________________________________________"
    cout << "|" + Grid (4) + "|" + Grid (5) + "|" + Grid (6) + "|"
    cout << "_____________________________________________________"
    cout << "|" + Grid (7) + "|" + Grid (8) + "|" + Grid (9) + "|"
    cout << "_____________________________________________________"
}

void get_move

//if array has been filled then the game has ended.
int number_of_moves = (0);
//to determine whose turn it is
char current_turn = '0'

// if winner has been found
bool foundwinner = false

//Check if game is over
bool gameover = false

//main function
int main ()

{
    //Game title
    cout << "Tic Tac Toe"
    cout << "   begin   "

    {
        //allowing user to enter name and be identified by own name
        cout << "Player one enter name"
        cin >> playerone
        cout << "Player two enter name"
        cin >> playertwo
    }
    //so player names can be shown on screen.
    cout << player one << "         "<< player two << endl;

  void grid (G)

while gameover = false

void determine_turn
{
    playerone = 'X'
    playertwo = 'O'
    char current_turn ='X'
    switch turn (current_turn)

}

void get_move
{
    int move [1-9]
    if char current turn = 'X'
    {
        cout << playerone << "select a location for 'X'" << endl;
        cin >> move [1-9]
        {
            if move (1)
            grid[1] = 'X'

            if move (2)
            grid [2] = 'X'

            if move (3)
            grid [3] = 'X'

            if move (4)
            grid [4] = 'X'

            if move (5)
            grid [5] = 'X'

            if move (6)
            grid [6] = 'X'

            if move (7)
            grid [7] = 'X'

            if move (8)
            grid [8] = 'X'

            if move (9)
            grid (9) = 'X'
        }
        display Grid (G)
    }
    else
    {
        cout << playertwo << "select location for 'O'" << endl;
        cin >> move [1-9]
        {
            if move (1)
            grid[1] = 'O'

            if move (2)
            grid [2] = 'O'

            if move (3)
            grid [3] = 'O'

            if move (4)
            grid [4] = 'O'

            if move (5)
            grid [5] = 'O'

            if move (6)
            grid [6] = 'O'

            if move (7)
            grid [7] = 'O'

            if move (8)
            grid [8] = 'O'

            if move (9)
            grid (9) = 'O'
        }
    }

}


void check win
{
    if
    grid (1) == grid (4) && grid (7) or
    grid (2) == grid (5) && grid (8) or
    grid (3) == grid (6) && grid (9) or
    grid (1) == grid (2) && grid (3) or
    grid (4) == grid (5) && grid (6) or
    grid (7) == grid (8) && grid (9) or
    grid (1) == grid (5) && grid (9) or
    grid (3) == grid (5) && grid (7)

    foundwinner = true
    {
        if current_turn = '0'
        winner = playerone
        cout << "the winner is" << playerone << endl;
        else
        winner = playertwo
        cout << "the winner is" << playertwo << endl;

    }
    else
    foundwinner = false
}
if foundwinner = true
or number_of_moves (9)
gameover = true

else
(i=0; i<9; i++)

return 0
Sorry to say that, but this has not much to do with C/C++.

- each line needs to end with a semicolon
- each function needs parenthesis
- comparison is always == // Note: two =
- assignment is always = // Note: one =
- code cannot exists outside a function (be carefull with the curly brace)
- if requires parenthesis
- arrays always start with 0. You define them with the number of fields, i.e.

int move [9];

0 is the first index to access a field of an array and according to the example above 8 is the very last


So what's your intention when it comes to line 15 and 16?
Topic archived. No new replies allowed.