C++:TrigraphSequence
lastmod 2018-08-17created 2015-03-264 edits
The C language has a set of substitution characters called trigraphs (TrigraphSequence) that take precedence over the preprocessor. This is because the character sets of some language regions cannot accommodate the entire C character set. (Most notably, ISO646 defines a character set of 82 characters, and it does not include some of the C character set.) In such cases C source code cannot be expressed, and trigraphs (Trigraph sequence) came into existence to make up for this. Trigraphs are substituted before any other preprocessing step, and there are 9 trigraphs in total. Each starts with two question marks (?) followed by one identifying character, and is replaced with some other character. The 9 are as follows.
With code like the following, you will see it print the '#' character.
Example
For reference, with C++ code like the following, the substitution only works correctly if you add the -ansi option.