According to C++'03 Standard 2.3/1:
Before any other processing takes place, each occurrence of one of the following sequences of three characters (“trigraph sequences”) is replaced by the single character indicated in Table 1.
---------------------------------------------------------------------------- | trigraph | replacement | trigraph | replacement | trigraph | replacement | ---------------------------------------------------------------------------- | ??= | # | ??( | [ | ??< | { | | ??/ | \ | ??) | ] | ??> | } | | ??’ | ˆ | ??! | | | ??- | ˜ | ----------------------------------------------------------------------------
In real life that means that code printf( "What??!\n" );
will result in printing What|
because ??!
is a trigraph sequence that is replaced with the |
character.
My question is what purpose of using trigraphs? Is there any practical advantage of using trigraphs?
UPD: In answers was mentioned that some European keyboards don't have all the punctuation characters, so non-US programmers have to use trigraphs in everyday life?
UPD2: Visual Studio 2010 has trigraph support turned off by default.
:-)
– Impractical