I am college student, learning C. I use CLion 2018.2.5 in macOS 10.14 mojave.
It's an easy problem "A plus B", here is my code:
#include <stdio.h>
int main() {
int a, b;
while (scanf("%d%d", &a, &b) != EOF) {
printf("%d", a + b);
}
return 0;
}
NOTE: There is NO Newline '\n' after "%d".
↓↓↓↓↓↓↓↓↓↓↓↓↓Output by clicking Debug in CLion:
(I typed "4 space 5 return 6 space 7 return command+D(EOF)")
/Users/i/CLionProjects/C_PersonalPractice/cmake-build-debug/sum
4 5
6 7
^D
913
Process finished with exit code 0
↓↓↓↓↓↓↓↓↓↓↓↓↓Output by clicking Run in CLion:
(I typed "4 space 5 return 6 space 7 return command+D(EOF)")
/Users/i/CLionProjects/C_PersonalPractice/cmake-build-debug/sum
4 5
96 7
13^D
Process finished with exit code 0
↓↓↓↓↓↓↓↓↓↓↓↓↓Output by GCC in Terminal:
(I typed: "4 space 5 return 6 space 7 return control+D(EOF)")
Last login: Fri Oct 26 13:35:34 on ttys005
MacBook-Pro:~ i$ /Users/i/sum ; exit;
4 5
96 7
13logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
[进程已完成]
In the debugging result, I found the IDE seems to display the calculation result together instead of displaying it instantly after entering two numbers.
Is it a feature or bug about debugging of CLion?
Update:
This code can be OK successfully during debugging as long as I type newline '\n' after "%d".
In addition, today I just encountered another similar bug related to EOF:
sending EOF to stdin in Clion IDE;
which had been confirmed by JetBrains: https://youtrack.jetbrains.com/issue/CPP-5704
Its solution is to disable "run.processes.with.pty" in Registry in CLion.
I think this problem could be complicated if considering all of the above factors: Debug or Run, type newline or not, disable or enable "run.processes.with.pty".