C++ printing twice BullCowGame

Hello !
The intro are getting printed twice and I don’t know why.

#include
#include
using namespace std;

void PrintIntro();
string GetGuessAndPrintBack();

int main()
{
PrintIntro();

// Loop number of turns asking guesses
constexpr int NumberOfTurns = 5;
for (int count = 1; count <= NumberOfTurns; count++)
{
GetGuessAndPrintBack();
cout << endl;
}

cout << endl;
return 0;
}

// Introduce the game
void PrintIntro()
{
constexpr int WordLength = 9;
cout << “Welcome to Bulls and Cows !\n”;
cout << “Can you guess the " << WordLength;
cout << " letter isogram I’m thinking of ?\n”;
cout << endl;
return;
}

//Get Player Guess
string GetGuessAndPrintBack()
{
PrintIntro();
cout << "Enter your guess: ";
string Guess = “”;
getline(cin, Guess);

// Print guess to player
cout << "Your guess was: " << Guess << endl;
return Guess;

}

Screenshot_1

PrintIntro in the wrong place

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms