سؤال

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.

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

نصائح أخرى

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top