As a matter of information, when I press control F5 I need to compile any changes I make prior to execution which does not seem to be in the video.
In regard to the code, I wrote a second function using void GetGuess rather than using string. The program executed well. Is this incorrect or just less elegant?
Here is the code:
#include
#include
using namespace std;
void PrintIntro();
void GetGuess();
// the entryy point for our application
int main()
{
PrintIntro();
GetGuess();
}
void PrintIntro() {
// introduce the game
constexpr int WORD_LENGTH = 9;
cout << “Welcome to Bulls and Cows, a fun word game” << endl;
cout << “can you guess the " << WORD_LENGTH;
cout << " letter isogram I am thinking of?” << endl;
return;
}
void GetGuess() {
// get a guess from the player
string Guess = “”;
cout << "Enter your guess? ";
getline(cin, Guess);
// repeat the guess back to them
cout << "Your guess was: " << Guess << endl;
cout << endl;
// get a guess from the player
cout << "Enter your guess? ";
getline(cin, Guess);
// repeat the guess back to them
cout << "Your guess was: " << Guess << endl;
cout << endl;
return;
}
Thanks