Curious trigraph sequence thing about ansi C
题
What was is it the original reason to use trigraph sequence of some chars to become other chars in ansi C like:
??=define arraycheck(a, b) a??(b??) ??!??! b??(a??)
becomes
#define arraycheck(a, b) a[b] || b[a]
解决方案
Short answer: keyboards/character encodings that didn't include such graphs.
From wikipedia:
The basic character set of the C programming language is a superset of the ASCII character set that includes nine characters which lie outside the ISO 646 invariant character set. This can pose a problem for writing source code when the keyboard being used does not support any of these nine characters. The ANSI C committee invented trigraphs as a way of entering source code using keyboards that support any version of the ISO 646 character set.
其他提示
Some old keyboards didn't have specific characters on them, so the language worked around it by letting you use trigraphs instead.