Hello,
don't know why the while_loop doesn't execute with CIN statement. It printed the statement before entering the loop, but it seems not entering the loop at all, even one time. When I entered the end-of-file command (CTRL - D) after the word: "jumped", the window disappeared. Attached are snapshots. Thank you very much.
P.S.: Please see the snapshots in the link here: https://www.dropbox.com/sh/9sjl4i3xknqnuxv/AAB8Rz7Vc0ZHbihbLEfFahYla?dl=0
cin reads until you press enter.
for your code to work, enter each word one by one with a return/enter key after each one.
its not that it did not enter the while loop, its that you are still on the 'cin' statement in the loop and its waiting to get past that.
window vanish ... just open a console and run from it is the way I deal with it. When the program ends the text remains. There are other ways. I thought end of file was ctrl+z.
edit ^^ this depends on OS. eof is z on windows, d on unix, apparently.
Thanks, but CIN read each word separated by white space. It works with windows 10 after I pressed the CRL+Z and Enter key. I don't know why it did not work with Linux-debian O.S. You can see the output snapshot at the link below: https://www.dropbox.com/s/mfd72j2ammyg5o5/Captured_Output.png?dl=0
On Linux, if you've already begun to type something on a line before you press ctrl-D, then you have to press ctrl-D twice to properly signal EOF.
The first such 'eof' causes the terminal driver to return the input so far to the calling program, but doesn't actually assert EOF. It's a bit like pressing 'enter', except no character is pushed into the stream.
It's only when you press ctrl-D at the start of an input line that the EOF state is set for the input stream.