So I'm making a battleship program and I'm having a little trouble trying to figure out the attack sequence. I thought i had it down but when I tried to compile it compiles but i get a warning saying
[Warning] comparison is always true due to limited range of data.
I think I'm doing it right. but im not sure.
basically i have a hidden computer array and a computer array that is visable on screen. if the hit is equal to ascii value 177 (default look for the board) then mark it with a O (a miss)
void play()
{ //declare varalbes
int col;
int row;
//prompt user to enter column to attack with numbers
cout<< "Enter a column to attack (ex. A=1, B=2 etc): " <<endl;
cin >> col;
col=col-1;
//prompt user to enter a column to attack
cout <<"Now enter a row: "<<endl;
cin >> row;
row = row -1;
//if coordinates player inputed doesnt equal ascii value 177 mark as hit.
if (seaOpponenthide[row][col] != '177') //warning error here.
{
seaOpponenthide[row][col]='X';
seaOpponent[col][row]='X';
cout <<"HIT!!" <<endl;
displayBoard();
}
//if coordinates player inputed equals ascii value 177 mark as miss.
elseif (seaOpponenthide[row][col] = '177')
{
seaOpponenthide[row][col]='O';
seaOpponent[col][row]='O';
cout <<"Miss!!" <<endl;
displayBoard();
}
play();
}
There's an extended ASCII value that goes higher than 177 but in not sure if that's what's giving me an error. I tried without the quotes and it still gives me an error. Not sure what's wrong..