c - eclipse ;逃生序列不起作用?

标签 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("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/

相关文章:

java - 将 Eclipse 动态 web 项目转换为带有模块的 maven 项目

C define语句函数调用一次还是每次使用宏?

c - 错误 : expected expression before ‘st’

c++ - gcov 和 switch 语句

c - 将从系统调用 open() 打开的文件传递给函数

eclipse - Subclipse - 将 SVN 存储库 check out 到非根文件夹中

java - Eclipse 无法关闭 BEA WebLogic 服务器

c# - 如何在一行代码中转义所有值得转义的字符?

java - 解析 XML,删除 & 之后的所有字符

python - pytest:使用 re.escape() 断言转义字符失败