fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. bool AskToPlayAgain()
  6. {
  7. string Response;
  8. cout << "That was fun! Would you like to play again? ";
  9. getline(cin, Response);
  10. // cout << "Is it y? " << (Response[0] == 'y' || Response [0] =='Y');
  11. if
  12. (Response[0] == 'y' || Response[0] == 'Y')
  13. return true;
  14. else if (Response[0] == 'n' || Response[0] == 'N')
  15. return false;
  16. //For other cases when 1st character is not 'n' or 'N' or 'y' or 'Y'
  17. return false;
  18. }
  19.  
  20. int main() {
  21. // do while (Response == 1)
  22. //PrintIntro();
  23. //PlayGame();
  24. //AskToPlayAgain();
  25. cout << "You said " << AskToPlayAgain();
  26. return 0;
  27. }
Success #stdin #stdout 0s 4508KB
stdin
n
stdout
That was fun! Would you like to play again? You said 0