tic tac toe please help.

Hi, I posted earlier about a programming assignment for school I am doing. I am in year twelve, and am doing software design as a subject. Before I posted a really terrible piece of coding full of errors, which i developed initially for the project. With the help of a friend, the code was able to become error free. however, I compile it and I go to run it, and when I run it, it executes to the part where players enter names, the player names are displayed, and space thats created.
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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
//SDD 2012
//Tic tac toe
//l

#include <iostream>
#include <string>

using namespace std;

string playerone;
string playertwo;

//variables for spaces in the game board
char G;
char Grid[9];

//tic tac toe board for game play
char Print_Grid (char G)
{
    cout << "__________________________\n";
    cout << "         |        |        \n";
    cout <<  Grid [0] && "|" && Grid [1] && "|" && Grid [2];
    cout << "         |        |        \n";
    cout << "__________________________\n";
    cout << "         |        |        \n";
    cout <<  Grid [3] && "|" && Grid [4]&& "|" && Grid [5];
    cout << "         |        |        \n";
    cout << "__________________________\n";
    cout << "         |        |        \n";
    cout <<  Grid [6] && "|" && Grid [7] && "|" && Grid [8];
    cout << "         |        |        \n";
    cout << "__________________________\n";


//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 ()
{
    cout << "Tic Tac Toe";
    cout << "   begin   ";

    //allowing user to enter name and be identified by own name
    cout << "player one enter name\n";
    cin >> playerone;
    cout << "player two enter name\n";
    cin >> playertwo;

    //so player names can be shown on the screen.
    cout << playerone << "          " << playertwo << endl;


    Print_Grid(G);

    //while loop
    while (gameover == false)
    {
        void determine_turn();
        void get_move();
        void check_win();
    }


    return 0;

}

void determine_turn()
{
    playerone = 'X';
    playertwo = 'O';

    if (current_turn == 'X') //if X just had a turn change to O
    {
        current_turn = 'O';
    }
    else
    {
        current_turn = 'X';
    }


}


void get_move ()
{
    int move;
    if (current_turn == 'X')
    {
        cout << playerone << "select a location for 'X'" << endl;
        cin >> move;

        if (move == 1)
        {
            Grid[0] = 'X';
        }
        if (move == 2)
        {
            Grid[1] = 'X';
        }
        if (move == 3)
        {
            Grid[2] = 'X';
        }
        if (move == 4)
        {
            Grid[3] = 'X';
        }
        if (move == 5)
        {
            Grid[4] = 'X';
        }
        if (move == 6)
        {
            Grid[5] = 'X';
        }
        if (move == 7)
        {
            Grid[6] = 'X';
        }
        if (move == 8)
        {
            Grid[7] = 'X';
        }
        if (move == 9)
        {
            Grid[8] = 'X';
        }
    }
    else
    {
        cout << playertwo << "select location for '0'" << endl;
        cin >> move;

        if (move == 1)
        {
            Grid[0] = 'O';
        }
        if (move == 2)
        {
            Grid[1] = 'O';
        }
        if (move == 3)
        {
            Grid[2] = 'O';
        }
        if (move == 4)
        {
            Grid[3] = 'O';
        }
        if (move == 5)
        {
            Grid[4] = 'O';
        }
        if (move == 6)
        {
            Grid[5] = 'O';
        }
        if (move == 7)
        {
            Grid[6] = 'O';
        }
        if (move == 8)
        {
            Grid[7] = 'O';
        }
        if (move == 9)
        {
            Grid[8] = 'O';
        }
    }
}


void check_win()
{
    if
    (
        ((Grid[0] == Grid[3]) && (Grid[0] == Grid[6])) ||
        ((Grid[1] == Grid[4]) && (Grid[1] == Grid[7])) ||
        ((Grid[2] == Grid[3]) && (Grid[2] == Grid[8])) ||
        ((Grid[0] == Grid[3]) && (Grid[0] == Grid[2])) ||
        ((Grid[3] == Grid[3]) && (Grid[3] == Grid[5])) ||
        ((Grid[6] == Grid[3]) && (Grid[6] == Grid[8])) ||
        ((Grid[0] == Grid[3]) && (Grid[0] == Grid[8])) ||
        ((Grid[2] == Grid[3]) && (Grid[2] == Grid[6]))
    )
    {
        foundwinner = true;
        if (current_turn == '0')
        {
            cout << "the winner is" << playerone << endl;
        }
        else
        {
            cout << "the winner is" << playertwo << endl;
        }
    }
    else
    {
        foundwinner = false;

        if (foundwinner = true && number_of_moves == 9)
        {
            gameover = true;
        }
    }
}
char Grid[9]; Not initialized with anything.
cout << Grid [0] && "|" && Grid [1] && "|" && Grid [2]; The ampersands in here, why? I think you were wanting to use operator<< instead. Not even sure what that does.
char Print_Grid (char G) Why are you passing in G? It's never used.

Might wanna stop using global variables, also. There's also better ways to do all of this, but I'll leave that to you to figure out :D That's the fun part
closed account (o1vk4iN6)
Some of these are very overcomplicated...

1
2
3
4
5
6
7
8
9
10
11

        if (move == 1)
        {
            Grid[0] = 'O'; // try to notice pattern, Grid[ x ], where x is the same as (move - 1), all this can be simplified to one line of code
        }
        if (move == 2)
        {
            Grid[1] = 'O';
        }

// 50 lines later 
one line of code?
Topic archived. No new replies allowed.