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'
I have a short deadline and im in a hurry to finish this. Your help would really be great. Thanks, Maryann.
line: 17 error: expected ',' or ';' before '=' token
line: 20 error: two or more data types in decleration of 'Grid'
Problem is here:
1 2 3 4 5 6 7 8 9 10
//variables for the spaces in the game board
char G = 1to9;
char Grid (G) = G; //(G) in definition of a regular variable is not allowed, delete it.
//tic tac toe board for game play
//void char is not a data type - you need void here because the function doesn't return anything
//also, this function has the same name name as the Grid variable above, which is causing the second error
//rename it to something like print_grid(G), because that's basically what it does voidchar Grid (G)
{
The next two errors:
line: 34 error: expected initializer before 'int'
line: 39 error: expected ',' or ';' before 'bool'
1 2 3 4 5 6 7 8 9 10 11 12
void get_move(); //need to add (); , always end statements with a ;
//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'; //again, end statements with semicolons
// if winner has been found
bool foundwinner = false; //again, end statements with semicolons
//Check if game is over
bool gameover = false; //again, end statements with semicolons
Hope that helps.
Let us know if you have any further questions.