I work in a school assignment and now I bang my head against the wall, trying to understand why my program does not behave the way I would like!
int main(){ string input; char choice; bool getChoice(char); string getInput(); CharConverter newInput; do{ cout << "Please enter a sentence.\n"; getline(cin, input); cout << newInput.properWords(input) << endl; cout << newInput.uppercase(input) << endl; cout << "Would you like to do that again?\n"; cin >> choice; } while (getChoice(choice) == true); return 0; }
This program works fine in the first round, but I have a problem when getChoice () == true, and the second is the second. In the second cycle, the program asks me to re-enter the sentence, but then just jumps to "Do you want to do this again?" without user input or output of the correct word () and uppercase () functions. I suspect there is something about getline that I donβt understand, but I have yet to find it in my search. Any help there?
edit: An error occurred in my original explanation.
source share