未知的元字符在C / C ++字符串字面量? [英] Unknown meta-character in C/C++ string literal?
问题描述
我创建了以下code段一个新项目:
I created a new project with the following code segment:
char* strange = "(Strange??)";
cout << strange << endl;
导致下面的输出
resulting in the following output:
(奇怪]
因此翻译'?) - >]
Thus translating '??)' -> ']'
调试它表明我的char *字符串文字实际上是一个价值,它是不是甲流的翻译。这显然不是我见过的元字符序列。
某种统一的code或者宽字符序列?我不这么认为......但是我已经试过禁用所有相关的项目设置,也没有用。
Debugging it shows that my char* string literal is actually that value and it's not a stream translation. This is obviously not a meta-character sequence I've ever seen. Some sort of Unicode or wide char sequence perhaps? I don't think so however... I've tried disabling all related project settings to no avail.
任何人有一个解释?
- 搜索:'问号,问号,右括号'C C ++字符串字面量
推荐答案
你看到的被称为 三字符的。
What you're seeing is called a trigraph.
在用大人的书面语言,一是问号足以满足任何情况。不要使用一个以上的时间和你永远不会再看到这一点。
In written language by grown-ups, one question mark is sufficient for any situation. Don't use more than one at a time and you'll never see this again.
GCC忽略默认情况下,三字母,因为几乎没有人使用它们故意。与 -trigraph
选项启用它们,或者告诉编译器与 -Wtrigraphs
选项警告你他们。
GCC ignores trigraphs by default because hardly anyone uses them intentionally. Enable them with the -trigraph
option, or tell the compiler to warning you about them with the -Wtrigraphs
option.
的Visual C ++ 2010也默认和报价 / ZC禁止它们:三字母
启用它们。我不能找到方法来启用或以前版本中禁用他们什么。
Visual C++ 2010 also disables them by default and offers /Zc:trigraphs
to enable them. I can't find anything about ways to enable or disable them in prior versions.
这篇关于未知的元字符在C / C ++字符串字面量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!