C Question

Multiple logical operator || (OR) conditions in for loop in C

I started studying C a week ago and decided to write my own tictactoe game for practise.

I have a game loop in main

for(int i = 1; player1.isWinner!=1 || player2.isWinner!=1 || noWinner!=1; i++){...}

Where i - counts turns and condition of end of the game is one of players has won, or no one has won (draw).

For now it quits executes only if all conditions are 1.

How to make it work right?

Answer Source

Is a value of 1 where someone won?

If so, then you would need check any of those conditions is true and loop if they are not:

!(player1.isWinner==1 || player2.isWinner==1 || noWinner==1)

Or using AND, check and loop when none are set:

(player1.isWinner!=1 && player2.isWinner!=1 && noWinner!=1)