我正在做一个基本的 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
By this, another sample text
The space is removed.
相反,我得到了这个:
This is a "sample text"
More text
This is getting overwritten
By this, another sample text
The spa ce is removed.
我在 Windows 上使用 Eclipse Cpp Oxygen 和 Cygwin 工具链来编译和运行代码。我不知道我做错了什么,我想我应该在这里寻求帮助。
最佳答案
Eclipse 内置的控制台不支持 \r
、\b
(和 \f
)字符。
有一个长期存在的错误 76936为此,已经开放了14年。但看起来并没有被修复。
关于c - eclipse ;逃生序列不起作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49831418/