The problem with your code is that, when you press 'd',the program not only runs case d, however it also runs the code to enter choice as it is in the same do while loop.Therefore, you need to skip the choice input. For that what if have done is that initialized variable m as a moderator. When 'd' is pressed, m is incremented and the if statement becomes false, therefore taking input only the string
if(m%2==0)
{cout << "A) Count the number of vowels in the string" << endl;
cout << "B) Count the number of consonants in the string" << endl;
cout << "C) Count both the vowels and consonants in the string" << endl;
cout << "D) Enter another string" << endl;
cout << "E) Exit the program" << endl;
cout << "Please select an option" << endl;
cin>>choice;
choice = tolower(choice);}
for the switch case 'd'
case 'd':
cout << "Please enter a sentence. (100 characters max.)" << endl;
m++;
cin.getline(input,SIZE);
cout << endl;
break;
Replacing getline with ignore doesn't solve the problem.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…