I have this code and I am having trouble figuring how to make it run without any errors, can anybody give me some pointers on how to fix it
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
class TicTacToe
{
private:
char theBoard [3][3];
public:
TicTacToe(void);
void playOneGame(void);
void switchPlayer(char &);
void showBoard(void);
void postMove(int, int, char);
char determineWinner(void);
};
int main (void)
{
//test the class by playing one game
TicTacToe Game1;
Game1.playOneGame();
return 0;
}
void TicTacToe::playOneGame(void)
{
//start a game and play until someone wins or a draw occurs...
const int MaxMoves = 9;
char currentPlayer = 'O';
int row = 0;
int clmn = 0;
char theWinner = ' ';
int nmbrOfMoves = 0; //keep track of the number of moves max is 9
do
{
switchPlayer(currentPlayer); //change player from x to o or vice versa
showBoard();
cout << "\n\nPlayer " << currentPlayer << endl; //get the players move
cout << "enter your row: ";
cin >> row;
cout << "enter your column: ";
cin >> clmn;
postMove(row, clmn, currentPlayer); //post the move to the board
theWinner = determineWinner(); //see if anyone won the game
nmbrOfMoves++; //keep track of the number of moves
}
while((theWinner == 'D') && (nmbrOfMoves < MaxMoves));
showBoard(); //show the ending board
if(theWinner != 'D') //declare a winner
{
cout << "\n\nThe Winner is player " << theWinner;
}
else
{
cout << "\n\nThe Game was a Draw";
}
}
TicTacToe::TicTacToe(void)
{
char theBoard [3][3];
for(int i = 0; i< size; i++)
{ for(int j = 0; j< size; j++)
{
theBoard[i][j] = ' ';
}
}
}
void TicTacToe::switchPlayer(char ¤tPlayer)
{
//switches the current player
Start
if(currentPlayer = 'x' || currentPlayer = 'X')
{
currentPlayer = 'X'
}
else
{
if(currentPlayer = 'o' || currentPlayer = 'O')
{
currentPlayer = 'O'
}
}
}
void TicTacToe::showBoard(void)
{
//displays the board
for(int i = 0; i< size; i++)
{
for(int j = 0; j< size; j++)
cout << " [ "<< theBoard[i][j] << " ] \n";
cout << endl;
}
}
void TicTacToe::postMove(int row, int col, char value)
{
//gets the users move and posts it to the board
}
char TicTacToe::determineWinner(void)
{
//analyzes the board to see if there is a winner
//returns a X, O indicating the winner
//if the game is a draw then D is returned
//check the rows
for (int i = 0; i < 3; i++)
{
if (theBoard[i][0] == theBoard[i][1] && theBoard[i][1] == theBoard[i][2] && theBoard[i][0] != ' ')
{
return theBoard[i][0];
}
}
//check the clmns
for (int i = 0; i < 3; i++)
{
if (theBoard[0][i] == theBoard[1][i] && theBoard[1][i] == theBoard[2][i] && theBoard[0][i] != ' ')
{
return theBoard[0][i];
}
}
//check the diagonals
if (theBoard[0][0] == theBoard[1][1] && theBoard[1][1] == theBoard[2][2] && theBoard[0][0] != ' ')
{
return theBoard[0][0];
}
if (theBoard[2][0] == theBoard[1][1] && theBoard[1][1] == theBoard[0][2] && theBoard[2][0] != ' ')
{
return theBoard[2][0];
}
return 'D';
}
Here are the error codes
Error 1 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 2 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 3 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 4 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 5 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 6 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 7 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 8 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 9 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 10 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 11 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 37
Error 12 error C2065: ' ' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 38
Error 13 error C2146: syntax error : missing ';' before identifier 'cout' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 38
Error 14 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 42
Error 15 error C2065: ' ' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 43
Error 16 error C2146: syntax error : missing ';' before identifier 'postMove' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 43
Error 17 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 44
Error 18 error C2146: syntax error : missing ';' before identifier 'nmbrOfMoves' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 45
Error 19 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 45
Error 20 error C2143: syntax error : missing ';' before '}' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 47
Error 21 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 51
Error 22 error C2143: syntax error : missing ';' before '{' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 52
Error 23 error C2181: illegal else without matching if \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 55
Error 24 error C2065: 'size' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 64
Error 25 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 74
Error 26 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 74
Error 27 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 74
Error 28 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 74
Error 29 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 74
Error 30 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 74
Error 31 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 74
Error 32 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 74
Error 33 error C2065: ' ' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 76
Error 34 error C2146: syntax error : missing ';' before identifier 'Start' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 76
Error 35 error C2065: 'Start' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 76
Error 36 error C2143: syntax error : missing ';' before 'if' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 76
Warning 37 warning C4305: '=' : truncation from 'char' to 'bool' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 76
Error 38 error C2106: '=' : left operand must be l-value \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 76
Error 39 error C2143: syntax error : missing ';' before '}' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 79
Warning 40 warning C4305: '=' : truncation from 'char' to 'bool' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 82
Error 41 error C2106: '=' : left operand must be l-value \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 82
Error 42 error C2143: syntax error : missing ';' before '}' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 85
Error 43 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 102
Error 44 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 102
Error 45 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 102
Error 46 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 102
Error 47 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 102
Error 48 error C3872: '0xa0': this character is not allowed in an identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 102
Error 49 error C2065: ' ' : undeclared identifier \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 104
Error 50 error C2143: syntax error : missing ';' before '}' \\ilabss\home$\D03279277\Documents\Visual Studio 2005\Projects\Lab6Ex2\Lab6Ex2\Lab6Ex2.cpp 104