Cant seem to find the solution to this although its probably starting me straight in the face.
Iv been at this for a few days now,can anyone help me spot the bug?
// test the bool
#include <iostream>
using namespace std;
main(){
int turn;
int var=2;
while(var!=1){
cout << "1 for x, 2 for o" << endl;
cin >> turn;
if(turn=1){
cout << "X" << endl;
turn=2; // o's turn
}
else if (turn=2){
cout << "O" << endl;
turn=1; // x's turn
}
}
}
the program will only print out the x,never the o,even if i press 2.Iv tried switching the turn variable to an int too.