in this small chess terminal app, at the end of black's turn, the code should check if move contains '#' if so, it should exit. The problem is, it automatically exits and doesn't check the second if statement, looping it back to label. Why is this?
#include <iostream>
int main(){
bool turn = true;
int turnNumber = 0;
bool mated = false;
label:
while(turn){
std::string move;
std::cout << "White to move: ";
std::cin >> move;
std::cout << move << '\n';
turn = false;
}
while(!turn){
std::string move;
std::cout << "Black to move: ";
std::cin >> move;
std::cout << move << '\n';
turn = true;
turnNumber+=1;
if(move.find('#')){
mated = true;
}
else if(!mated){
goto label;
}
}
}
I tried switching the statements around and removing the else, but that didn't work.