Here's my program so far:
int main()
{
char choice = 'D';
string inputString;
cout << "Please input a string." << endl;
getline(cin, inputString);
LetterCount letterCount(inputString);
while(choice != 'E')
{
cout << "Please choose from the following: " << endl
<< "A) Count the number of vowels in the string." << endl
<< "B) Count the number of consonants in the string." << endl
<< "C) Count both the vowels and consonants in the string." << endl
<< "D) Enter another string." << endl << "E) Exit the program." << endl;
cin >> choice;
if(choice == 'A' || choice == 'a')
{
cout << "There are " << letterCount.vowelCount() << " vowels in this string." << endl;
}
else if(choice == 'B' || choice == 'b')
{
cout << "There are " << letterCount.consonantCount() << " consonants in this string." << endl;
}
else if(choice == 'C' || choice == 'c')
{
cout << "There are " << letterCount.vowelCount() << " vowels and " << letterCount.consonantCount()
<< " consonants in this string, for a total of " << (letterCount.vowelCount() + letterCount.consonantCount())
<< " letters." << endl;
}
else if(choice == 'D' || choice == 'd')
{
cout << "Please type in another string." << endl;
getline(cin, inputString);
letterCount.setInputString(inputString);
}
else
{
choice = 'E';
}
}
}
I'm only including the main as it's the issue giver here, everything else functions properly.
The problem comes up when I use choice 'D' (input a new string.) as soon as enter is hit, the program returns right to the choice prompt and sets the inputString variable to blank (not the word blank, but nothing in it)
the first getline(cin, inputString) works perfectly fine, the second one is the issue giver...any suggestions?