Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 日食转义序列don';不行?_C_Eclipse_Escaping - Fatal编程技术网

C 日食转义序列don';不行?

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

我正在做一个基本的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("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.