Wanted to know whether a for-loop is better or if I should stick with a while loop. And if so why or why not.
srand((unsigned) time(NULL));
bool result;
bool end = false;
int win, lose;
char answer;
win = lose = 0;
while (!end) {
result = play_game();
if (result) {
printf("You win!\n\n");
++win;
} else {
printf("You Lose!\n\n");
++lose;
}
printf("Do you want to play again (y/n) ");
if ((toupper(answer = getchar())) == 'Y') {
end = false;
} else if ((toupper(answer = getchar())) == 'N'){
end = true;
}
}