No error, but the loop doesn't executed.

General questions regarding the usage of CodeLite
Noone
CodeLite Curious
Posts: 7
Joined: Thu Aug 13, 2020 4:50 am
Genuine User: Yes
IDE Question: C++
Contact:

No error, but the loop doesn't executed.

Post 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,
You do not have the required permissions to view the files attached to this post.
DavidGH
CodeLite Plugin
Posts: 819
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

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

Post 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
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

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

Post 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.
Noone
CodeLite Curious
Posts: 7
Joined: Thu Aug 13, 2020 4:50 am
Genuine User: Yes
IDE Question: C++
Contact:

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

Post 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,
You do not have the required permissions to view the files attached to this post.
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

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

Post 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
Noone
CodeLite Curious
Posts: 7
Joined: Thu Aug 13, 2020 4:50 am
Genuine User: Yes
IDE Question: C++
Contact:

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

Post 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,
You do not have the required permissions to view the files attached to this post.
User avatar
Jarod42
CodeLite Expert
Posts: 240
Joined: Wed Sep 30, 2009 5:54 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

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

Post 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..
Noone
CodeLite Curious
Posts: 7
Joined: Thu Aug 13, 2020 4:50 am
Genuine User: Yes
IDE Question: C++
Contact:

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

Post 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,
You do not have the required permissions to view the files attached to this post.
Post Reply