Hi I am trying to program a simple tic tac toe game, and whenever I compile it says:
error: ISO C== forbids comparison between pointer and integer
[-fpermissive] } while(input != "Quit");
^
Here is my code:
#include <iostream>
using namespace std;
/*
Board;
1 | 2 | 3
---|---|---
4 | 5 | 6
---|---|---
7 | 8 | 9
*/
char square[9] = {'1','2','3','4','5','6','7','8','9'};
char input;
void board();
main()
{
do
{
board();
switch (input)
{
case 1:
square[1] = 'X';
case 2:
square[2] = 'X';
case 3:
square[3] = 'X';
case 4:
square[4] = 'X';
case 5:
square[5] = 'X';
case 6:
square[6] = 'X';
case 7:
square[7] = 'X';
case 8:
square[8] = 'X';
case 9:
square[9] = 'X';
default:
cout << "Invalid Input";
}
} while(input != "Quit"); //Here is where it is an error
if(input == "Quit")
{
return 1;
}
cout << "\n\n";
return 0;
}
void board() //Builds the board
{
cout << "\n\n\tTicTacToe\n\n";
cout<<" "<<square[0]<<" | "<<square[1]<<" | "<<square[2]<< endl;
cout << "---|---|---" << endl;
cout<<" "<<square[3]<<" | "<<square[4]<<" | "<<square[5]<< endl;
cout << "---|---|---" << endl;
cout<<" "<<square[6]<<" | "<<square[7]<<" | "<<square[8]<< endl;
cout << "Player 1 Make a Move: ";
cin.get();
cin >> input;
}
FYI, this isn't close to the full game, I am just trying to figure out how I will code some parts of the game.