【发布时间】:2016-11-05 06:22:20
【问题描述】:
我在 Linux Mint 上使用 g++ 版本 4:4.8.2-1ubuntu6 和 Eclipse 3.8。
我的 C++ 书中的以下示例无法按预期工作:
//bondini.cpp -- using escape sequences
#include <iostream>
int main()
{
using namespace std;
cout << "\aOperation \"HyperHype\" is activated\n";
cout << "enter sercret code:________\b\b\b\b\b\b\b\b";
long code;
cin >> code;
cout << "\aYou entered: " << code << "...\n";
cout << "\aCode OK! Commencing Z3!\n";
return 0;
}
我在运行程序时得到以下结果:
在 Eclipse 和目录中,我使用的是 UTF-8 编码。为什么 '\a' 没有按应有的声音播放,而 '\b' 没有将光标向后移动一个空格,而 '\n' 却正常工作。
edit:据我了解,是编译器搞得一团糟。 --> 我错了,在终端可以正常工作,但是 eclipse 'terminal' 不行。
【问题讨论】:
-
是否支持特殊字符取决于终端。
-
当我直接从终端运行它时,它工作正常。所以它似乎是eclipse“终端”问题。
标签: c++ eclipse linux-mint g++4.8