1

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]
mu is too short
  • 426,620
  • 70
  • 833
  • 800
edgarmtze
  • 24,683
  • 80
  • 235
  • 386

2 Answers2

4

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.

http://en.wikipedia.org/wiki/Digraphs_and_trigraphs

K-ballo
  • 80,396
  • 20
  • 159
  • 169
1

Some old keyboards didn't have specific characters on them, so the language worked around it by letting you use trigraphs instead.

MikeP
  • 7,829
  • 33
  • 34
  • mmm, interesting, so it was back in 1983? or something? – edgarmtze Sep 11 '11 at 04:58
  • 1
    It's not just that they keyboards might not have the characters on them; the *character sets* themselves might have no way to encode those characters. For example, EBCDIC doesn't have `{` and `}` I believe. – Gabe Sep 11 '11 at 05:04