Why is my string outputting twice?

Hey guys!

I'm working an an assignment for C++, and I've almost got it figured out--except for one little glitch. When I run the program, the prompt I am giving the user before I collect their data, shows up twice in row. Here's the part of the code I'm referring to:


#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

// method prototypes
void characterInstructions();
void phraseInstructions(); //
char getCharacter();
string getString(); //
string maskLetter(char keyCharacter, string theString); //
string removeCharacter(char keyCharacter, string theString); //
int countKey(char keyCharacter, string theString);//
string newStr1;
string newStr2;

//intialize main sequence
int main()
{
characterInstructions();
char keyCharacter = getCharacter();
cout << keyCharacter;
phraseInstructions();
string theString = getString();
cout << theString <<endl;
string maskStr = maskLetter(keyCharacter, theString);
cout << "mask string is:"<<maskStr<<endl;
string removeStr = removeCharacter(keyCharacter, theString);
cout << "remove string is:"<<removeStr <<endl;
}



//... blah blah blah, this is a bunch of other code that works fine...




//states phrase instructions for character
void phraseInstructions()
{
string instructions;
instructions =
"\nPlease enter a phrase or sentence >= 4 characters: \n";
cout << instructions;
}

//get theString from user
string getString()
{
string theString;
//while the phrase is less than or equal to four characters in length, keep user in the loop
cin >> theString;
while (theString.length() <=4)
{
phraseInstructions();
cin >> theString;
}
return theString;
}
Registered users can post here. Sign in or register to post.