First of all, here is my code:
string text;
do {
cout << "Enter text: ";
ws(cin);
getline(cin, text);
} while (!text.empty());
// do stuff
What I want my code to do ?
- Check if the user input is empty ;
if the userinput = empty, loop to the beginning and he has to enter new text.
If userinput != empty, get out of the loop and continue the program.
What is my code doing ?
- When I enter a text, the loop start from the beginning and I have to retype a text.
- When I do not enter anything and just type enter, my program is indefinitely waiting and I need to Ctrl+C to exit.