问题描述
使用CLion时,我发现输出有时会中断。
When using CLion I have found the output sometimes cuts off.
例如,运行代码时:
main.cpp
#include <stdio.h>
int main() {
int i;
for (i = 0; i < 1000; i++) {
printf("%d\n", i);
}
fflush(stdout); // Shouldn't be needed as each line ends with "\n"
return 0;
}
预期产量
预期输出显然是换行上每个数字的0-999
The expected output is obviously the numbers 0-999 on each on a new line
实际输出
在CLion中多次执行代码后,输出通常会更改:
After executing the code multiple times within CLion, the output often changes:
- 有时它可以完美执行并显示所有数字0-999
- 有时它会在不同的点截断(例如0-840)
- 有时它不会t输出任何内容
返回代码始终为0!
截图
在终端中运行代码(即不在CLion本身中运行)
但是,在编译和运行代码时,代码会完美地输出数字0-999在终端上。
However, the code outputs the numbers 0-999 perfectly when compiling and running the code using the terminal.
我花了很多时间在想这是我的代码和内存问题,直到我终于意识到这只是一个问题。 CLion。
I have spent so much time on this thinking it was a problem with my code and a memory issue until I finally realised that this was just an issue with CLion.
操作系统:Ubuntu 14.04 LTS
OS: Ubuntu 14.04 LTS
版本:2016.1
构建:#CL-145.258
Build: #CL-145.258
更新
一种合适的解决方法是在调试模式下运行代码(感谢@olaf)。
A suitable workaround is to run the code in debug mode (thanks to @olaf).
推荐答案
共识是这是一个IDE问题。因此,我已经报告了该错误。
The consensus is that this is an IDE issue. Therefore, I have reported the bug.
一种合适的解决方法是在调试模式下执行代码(无需断点)。
A suitable workaround is to execute the code in debug mode (no breakpoint required).
此错误修复后,我将更新此问题。
I will update this question, as soon as this bug is fixed.
警告:除非JetBrains特别询问,否则您不应在注册表中更改信息。注册表不在主菜单中是有原因的!使用以下解决方案需要您自担风险!!!
JetBrains已与我联系并提供了合适的解决方案:
JetBrains have contacted me and provided a suitable solution:
- 转到查找操作对话框(CTRL + SHIFT + A)
- 搜索注册表...
- 取消勾选
run.processes.with.pty
- Go to the Find Action Dialog box (CTRL+SHIFT+A)
- Search for "Registry..."
- Untick
run.processes.with.pty
该错误已添加到此处:
The bug has been added here:https://youtrack.jetbrains.com/issue/CPP-6254
随时可以投票!
这篇关于执行程序时,CLion IDE的输出有时会中断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!