int main ()
{
string xstring;
int choice;
int Q;
cout << "Enter a string: ";
cin >> xstring;
do
{
cout << "USE THIS MENU TO MANIPULATE YOUR STRING\n";
cout << "----------------------------------------\n";
cout << "1) Inverse the string\n";
cout << "2) Reverse the string\n";
cout << "3) To Uppercase\n";
cout << "4) Jumble String\n";
cout << "5) Count Number of Words\n";
cout << "6) Count Constants\n";
cout << "7) Enter a Different String\n";
cout << "8) Print The String\n";
cout << "Q) Quit\n";
cin >> choice;
}
while (choice != 'Q');
system("PAUSE");
return 0;
}
As Annatar pointed out, choice is an integer instead of a character, so on line 26 if you input a character, the input operation will fail, leaving choice uninitialized when you compare to it on line 29. There is an extremely small chance that it happens to compare equal since it is left uninitialized.
omg i feel pretty dumb lol. Just one more quick question, when i use a switch statement for the string manipulation options, i would put that inside the do-while loop or would i put it on the outside of the do-while loop?(The string needs to be continuously manipulated, depending on what input the user uses)