C 日食转义序列don';不行?
我正在做一个基本的C教程。在一个示例中,给出了该代码以引入转义序列:C 日食转义序列don';不行?,c,eclipse,escaping,C,Eclipse,Escaping,我正在做一个基本的C教程。在一个示例中,给出了该代码以引入转义序列: #include <stdio.h> int main() { printf("This is a \"sample text\"\n"); printf("\tMore text\n"); printf("This is getting overwritten\r"); printf("By this, another sample text\n"); printf("T
#include <stdio.h>
int main()
{
printf("This is a \"sample text\"\n");
printf("\tMore text\n");
printf("This is getting overwritten\r");
printf("By this, another sample text\n");
printf("The spa \bce is removed.\n");
return 0;
}
相反,我得到的是:
This is a "sample text"
More text
This is getting overwritten
By this, another sample text
The spa ce is removed.
我在Windows上使用EclipseCPP和Cygwin工具链来编译和运行代码。我不知道我做错了什么,我想我应该在这里寻求帮助。在linux中,您的示例完全按照您的预期工作。可能在windows中,\r被视为类似\n。
相反,在linux终端上,\r将光标(正确地)放在行的第一个字符上。Eclipse内置的控制台不支持
\r
,\b
(和\f
)字符
有一个长期存在的错误,这已经开放了14年。但看起来不像是固定的。不需要猜测。Windows处理
\r
通常很好。显然这是一个Eclipse的东西,而不是Windows的东西。
This is a "sample text"
More text
This is getting overwritten
By this, another sample text
The spa ce is removed.