What does "??!?!" mean in C language?

Asked

Viewed 6,231 times

88

Once I saw a code in C with the following line:

...
if (condicao1 ??!??! condicao2){
/* faca algo */
}
...

What does "??!?!" mean in C language?

3 answers

95


It means the same thing ||.

In some places people do not have all the symbols necessary to program in C on their keyboards, hence the Graphs were created:

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

??!??! = (??!)(??!) = (|)(|) = ||.

As mentioned by @Laerte, this has fallen into disuse. Nowadays it only appears in demonstrations of obscure constructions that can be done in C and C++.

  • 7

    +1 for the classic tip to use in the "International Dark Code Competition in C"! (http://www.ioccc.org/)

33

??! is a trigraph equivalent to the logical expression || (or)

This was invented because these 9 characters are not part of the ISO 646. Thus, in order to be able to program on any keyboard compatible with this standard, the graphs were created.

Nowadays this is so useless that some compilers (like GCC itself) have decided to leave them out by default. To enable trigraphs in GCC, you must pass -trigraphs per parameter on the build line.

  1. http://renangreinert.blogspot.com.br/2011/08/nao-use-trigrafos.html
  • 5

    +1 for pointing out a specific case (GCC does not use by default).

32

The C compiler, when viewing the characters ??! in sequence, transforms them into |.

If I’m not mistaken this is due to the fact that formerly were not very common computers with the key |.

That is to say, ??!??! is the same as ||, the binary operator "OR".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.