I need to do an assignment where I have a game but I would like to add, would you like to play and after you play the game, ask if you would like to play again using the while loop
You can implement the while loop in main like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
int main()
{
bool running = true;
while (running)
{
// play your game here
cout << "Want to play again(y/n): ";
char answer;
cin >> answer;
cin.ignore(256, '\n');
running = answer == 'y';
}
}