Comma operator considered harmful
-
From a console tic-tac-toe game: (drawing function)
for (int x = 0, y = 0; y < 3; y+=((x==2)?1:0),x+=((x==2)?-2:1) ) {
cout << boardStrings[board[x][y]] << ((x == 2) ? "\n" : "");
}:((
-
From a console tic-tac-toe game: (drawing function)
for (int x = 0, y = 0; y < 3; y+=((x==2)?1:0),x+=((x==2)?-2:1) ) {
cout << boardStrings[board[x][y]] << ((x == 2) ? "\n" : "");
}:((
-
From a console tic-tac-toe game: (drawing function)
for (int x = 0, y = 0; y < 3; y+=((x==2)?1:0),x+=((x==2)?-2:1) ) {
cout << boardStrings[board[x][y]] << ((x == 2) ? "\n" : "");
}:((
-
From a console tic-tac-toe game: (drawing function)
for (int x = 0, y = 0; y < 3; y+=((x==2)?1:0),x+=((x==2)?-2:1) ) {
cout << boardStrings[board[x][y]] << ((x == 2) ? "\n" : "");
}:((
That's not really bad, to me. Initialising and updating two variables in a loop is one of the well understood allowed places to use a comma. The thing that's wrong with this code is that the 3x3 nature of the board should be a variable (or at least a constant), not in there as a magic number 5 times.