Logo

What does the ??!??! operator do in C?

In modern C, there is no ??!??! “operator.” What’s really happening is that C’s trigraph feature is transforming the sequence ??! into a single character |. Hence, ??!??! becomes ||. This effectively gives you the logical OR operator (||) in your source code if trigraphs are enabled.

What Are Trigraphs?

Trigraphs are obsolete or rarely used character sequences introduced in very old versions of the C standard to allow programmers to type certain characters on keyboards that didn’t support them. A trigraph consists of ?? followed by a third character, and the C preprocessor translates it into a single character.

For example:

  • ??= becomes #
  • ??( becomes [
  • ??) becomes ]
  • ??< becomes {
  • ??> becomes }
  • ??/ becomes \
  • ??' becomes ^
  • ??- becomes ~
  • ??! becomes |

Therefore:

  • ??!??! translates to ||.

Practical Implications

  1. Not a Real Operator

    • There’s no dedicated “double-trigraph operator” in the language. It’s just two trigraph sequences back to back, each turning into |, resulting in ||.
  2. Logical OR

    • After translation, || is the logical OR operator (e.g., if (a ??!??! b) is effectively if (a || b)).
  3. Obsolete Feature

    • Trigraphs are officially deprecated in recent C standards (and some compilers may disable them by default). You rarely—if ever—see them in modern code.
  4. Confusing to Readers

    • Even when they were standard, trigraphs often caused confusion. Most developers prefer straightforward characters over trigraphs, which is why they fell out of favor.

Recommended Resources

Bottom Line

If you see ??!??! in C code and wonder what it does, know that it becomes || via the trigraph translation phase. This is simply the logical OR operator once the preprocessor is done. However, trigraphs are an archaic feature of the language and best avoided in modern coding practices.

CONTRIBUTOR
TechGrind