I’m not sure if it is my VS or not because I have tried fixing and comparing my code exactly to the one in the video and then doing the same by taking the GitHub clone and running it and end up with the same results.
I end up in the picture where it will close out the console. I already looked to see if I have the properties set up correctly which I do, to have console selected under system and I am running test without debugging and I have tried with ctrl + f5.
#include <iostream>
#include <string>
using namespace std;
void PrintIntro();
void PlayGame();
string GetGuess();
bool AskToPlayAgain();
// the entry point for our application
int main()
{
PrintIntro();
PlayGame();
AskToPlayAgain();
return 0; // exit the application
}
// introduce the game
void PrintIntro()
{
constexpr int WORD_LENGTH = 5;
cout << "Welcome to Bulls and Cows, a fun word game.\n";
cout << "Can you guess the " << WORD_LENGTH;
cout << " letter isogram I'm thinking of?\n";
cout << endl;
return;
}
void PlayGame()
{
// loop for the number of turns asking for guesses
constexpr int NUMBER_OF_TURNS = 5;
for (int count = 1; count <= NUMBER_OF_TURNS; count++)
{
string Guess = GetGuess();
cout << "Your guess was: " << Guess << endl;
cout << endl;
}
}
string GetGuess()
{
// get a guess from the player
cout << "Enter your guess: ";
string Guess = "";
getline(cin, Guess);
return Guess;
}
bool AskToPlayAgain()
{
cout << "Do you want to play again? ";
string Response = "";
getline(cin, Response);
return (Response[0] == 'y') || (Response[0] == 'Y');
}