I'm getting the following error
error: no match for 'operator&&' in 'board[0][0] && board[0][1]'
My code is the following:
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
string board[3][3];
board[0][0] = "[ ]";
board[0][1] = "[ ]";
board[0][2] = "[ ]";
board[1][0] = "[ ]";
board[1][1] = "[ ]";
board[1][2] = "[ ]";
board[2][0] = "[ ]";
board[2][1] = "[ ]";
board[2][2] = "[ ]";
string choice;
int counter;
do
{
for(counter=0;counter<5;counter++)
{
cout<<board[0][0]<<board[0][1]<<board[0][2]<<endl;
cout<<board[1][0]<<board[1][1]<<board[1][2]<<endl;
cout<<board[2][0]<<board[2][1]<<board[2][2]<<endl;
cout<<"(Player 1) Tell me the coordinates of where you want your X togo: ";
cin>>choice;
cout<<endl;
if(choice=="1,1")
{
board[0][0] = "[X]";
}
else if(choice=="1,2")
{
board[1][0] = "[X]";
}
else if(choice=="1,3")
{
board[2][0] = "[X]";
}
else if(choice=="2,1")
{
board[0][1] = "[X]";
}
else if(choice=="2,2")
{
board[1][1] = "[X]";
}
else if(choice=="2,3")
{
board[2][1] = "[X]";
}
else if(choice=="3,1")
{
board[0][2] = "[X]";
}
else if(choice=="3,2")
{
board[1][2] = "[X]";
}
else if(choice=="3,3")
{
board[2][2] = "[X]";
}
if(board[0][0] && board[0][1] && board[0][2] == "[X]" || board[1][0] && board[1][1] && board[1][2] == "[X]" || board[2][0] && board[2][1] && board[2][2] == "[X]" || board[0][0] && board[1][0] && board[2][0] == "[X]" || board[0][1] && board[1][1] && board[2][1] == "[X]" || board[0][2] && board[1][2] && board[2][2] == "[X]" || board[0][0] && board[1][1] && board[2][2] == "[X]" ||board[2][0] && board[1][1] && board[0][2] == "[X]" ||)
{
cout<<"Player 1 wins!"<<endl;
}
}
}
while(counter<5);
return 0;
}
The line the error is on is the following:
if(board[0][0] && board[0][1] && board[0][2] == "[X]" || board[1][0] && board[1][1] && board[1][2] == "[X]" || board[2][0] && board[2][1] && board[2][2] == "[X]" || board[0][0] && board[1][0] && board[2][0] == "[X]" || board[0][1] && board[1][1] && board[2][1] == "[X]" || board[0][2] && board[1][2] && board[2][2] == "[X]" || board[0][0] && board[1][1] && board[2][2] == "[X]" ||board[2][0] && board[1][1] && board[0][2] == "[X]" ||)