I created a new project with the following code segment:
char* strange = "(Strange??)";
cout << strange << endl;
resulting in the following output:
(Strange]
Thus translating '??)' -> ']'
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.
Anyone have an explanation?
- search : 'question mark, question mark, close brace' c c++ string literal
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 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 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.