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 » Tue Aug 18, 2020 4:10 am

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: 676
Joined: Wed Sep 03, 2008 7:26 pm
Contact:

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

Post by DavidGH » Tue Aug 18, 2020 12:58 pm

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

Jarod42
CodeLite Expert
Posts: 190
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 » Tue Aug 18, 2020 11:45 pm

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 » Wed Aug 19, 2020 4:53 am

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.

Jarod42
CodeLite Expert
Posts: 190
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 » Wed Aug 19, 2020 11:05 am

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 » Wed Aug 19, 2020 1:56 pm

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.

Jarod42
CodeLite Expert
Posts: 190
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 » Sat Aug 22, 2020 4:28 pm

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 » Sat Aug 22, 2020 10:38 pm

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