Page 1 of 1

No error, but the loop doesn't executed.

Posted: Tue Aug 18, 2020 4:10 am
by Noone
Hello,

I 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.

Best regards,

Re: No error, but the loop doesn't executed.

Posted: Tue Aug 18, 2020 12:58 pm
by DavidGH
Hi,

This is a CodeLite forum. Your question seems to be language-related, not about CodeLite. I suggest you ask elsewhere e.g. stackoverflow.

Regards,

David

Re: No error, but the loop doesn't executed.

Posted: Tue Aug 18, 2020 11:45 pm
by Jarod42
You might use debugger to verify your assumption (add breakpoint inside the loop).

Currently, you don't flush output, so it might just not been yet displayed and waiting for new input.

Re: No error, but the loop doesn't executed.

Posted: Wed Aug 19, 2020 4:53 am
by Noone
Thanks, Jarod42. It does work with Windows 10 system, but not with Linux-Debian 10 O.S. The only difference was the end-of-file key. Attached is the output (snapshot).
Regards,

Re: No error, but the loop doesn't executed.

Posted: Wed Aug 19, 2020 11:05 am
by Jarod42
Which terminal do you use? I suspect that terminal used on linux closes itself on Ctrl-D.

You might try different terminal in Settings/Preferences/Terminal

Re: No error, but the loop doesn't executed.

Posted: Wed Aug 19, 2020 1:56 pm
by Noone
Thank you very much, Jrod42. You're correct. The problem was terminal. I have never suspected the problem was caused by terminal. You can see a new output from the snapshot attached.
Regards,

Re: No error, but the loop doesn't executed.

Posted: Sat Aug 22, 2020 4:28 pm
by Jarod42
Unrelated to codelite.

As I previously said, you don't **flush** output (`std::flush` or `std::endl`) so `std::cout` is only flushed automatically (when internal buffer is full) or on destruction..

Re: No error, but the loop doesn't executed.

Posted: Sat Aug 22, 2020 10:38 pm
by Noone
Thank you very much, Jarod42. I was using endl, but still need to pressed the "Enter key" to get the last cout. However, I hit the "Enter key" without pressing CTR-D by mistake, then all printed out. So, I don't understand why CTR-D is not needed. Please see the attached snapshot.
Best regards,