My solution, GetGuess and RepeatGuess separated

#include <iostream>
#include <string>

using namespace std;

void PrintIntro();
void PlayGame();
string GetGuess();

// the entry point of our application
int main()
{
	PrintIntro();

	PlayGame();
	
	return 0;
}

// introduce the game
void PrintIntro()
{
	constexpr int WORD_LENGTH = 5;
	cout << "Welcome to Bulls and Cows, a fun word game." << endl;
	cout << "Can you guess the " << WORD_LENGTH;
	cout << " letter isogram I'm thinking of?" << endl;
	cout << endl;
	return;
}

// get a guess from a player
string GetGuess()
{
	cout << "Enter your guess: ";
	string Guess = "";
	getline(cin, Guess);
	return Guess;
}

// repeat the guess back to them
void RepeatGuess()
{
	cout << "You typed \"" << GetGuess() << "\"." << endl;
	return;
}

void PlayGame()
{
	// loop for the number of turns asking for guesses
	constexpr int NUMBER_OF_GUESSES = 5;
	for (int i = 0; i < NUMBER_OF_GUESSES; i++)
	{
		RepeatGuess();
		cout << endl;
	}
	return;
}

Result:**Result:**Result:

Privacy & Terms