c++ forbids comparison pointer and integer

August 26, 2010 at 21:02:06
Specs: Win7 home, 2.6ghz / 8gb
Using CodeBlocks, GNU GCC
relevant code:

char board[3][3]={{' ',' ',' '},{' ',' ',' '},{' ',' ',' '}};
bool playerTurn(){
printBoard();
if(firstRound){cout<<"Input must be in \'X Y\' format\n";}
int in[2]={0,0};
while(true){
cout<<"Where would you like to place you mark?\n>";
cin>>in[0]>>in[1];
if(cin.good()){break;}
else{cin.clear();cin.ignore(INT_MAX,'n');continue;}
if((in[0]!=0&&in[0]!=1&&in[0]!=2)||(in[1]!=0&&in[1]!=1&&in[1]!=2)){
cout<<"\nInput must be in \'X Y\' format\n";continue;}
else{
if((board[in[0],in[1]])!=' '){ //line 99
cout<<"Spot already taken"<<endl;}}
}//input and check
board[in[0],in[1]]=playMark; //line 102
return evalBoard();
}//playerTurn

errors:
In function `bool playerTurn()':|
99|warning: left-hand operand of comma has no effect|
99|error: ISO C++ forbids comparison between pointer and integer|
102|warning: left-hand operand of comma has no effect|
102|error: incompatible types in assignment of `char' to `char[3]'|


See More: c++ forbids comparison pointer and integer

Report •

#1
August 26, 2010 at 21:24:52
Your problem: board[in[0],in[1]]

Report •

#2
August 26, 2010 at 21:28:06
Yes, I know where it is, I don't know what it is so I can't fix it.
What exactly is causing the error?

Report •

#3
August 26, 2010 at 21:38:46
You can only have a single number in braces. The correct syntax is biased off your declaration:
board[in[0]][in[1]]


Report •

Related Solutions

#4
August 26, 2010 at 21:43:20
I see, Thank you.

Report •

Ask Question