[英]CLion - Carriage return? \r
I am using the CLion IDE and I am trying to do a carriage return. 我正在使用CLion IDE,我正在尝试回车。
I am doing a print statement in C and have the following syntax: 我在C中做一个print语句,并具有以下语法:
printf("\\rHello World!");
which is inside a loop. 这是一个循环。 The loop still prints every
Hello World
on its own line. 循环仍然在自己的行上打印每个
Hello World
。 There are no \\n
's in my program. 我的程序中没有
\\n
。 I've tried changing the line separators
options to unix
mac OS
and windows
and none of them change the functionality. 我已经尝试将
line separators
选项更改为unix
mac OS
和windows
,但没有一个更改功能。 Google has also led me to no useful answers. 谷歌也让我没有得到有用的答案。
int main()
{
int i = 0;
while (i < 5000000)
{
printf("\rThis is line number %d!", i++);
}
return 0;
}
My expected output is only a single line of text in the console window. 我的预期输出只是控制台窗口中的一行文本。
Thanks. 谢谢。
Your problem is PuTTY console, that is used in CLion by default. 您的问题是PuTTY控制台,默认情况下在CLion中使用。 You can switch it off in Registry:
您可以在注册表中将其关闭:
Help | Find Action | Registry... =>
run.processes.with.pty [ ] <- uncheck
I recommend you modify the program: 我建议你修改程序:
#include <iostream>
int main() {
int i = 0;
while (i < 500) {
printf("\rThis is line number %d!", i++);
fflush(stdout); // <- add this call
}
return 0;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.