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

80

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

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

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

    
asked by vs06 04.02.2014 в 12:20
source

3 answers

90

Means the same as || .

In some places people do not have all the symbols needed to program C on their keyboards, hence the trigraphs 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 ++.

    
answered by 04.02.2014 / 12:27
source
33

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

If I'm not mistaken this is due to the fact that in the old days computers with the | key were not very common.

That is, ??!??! is the same as || , the binary operator "OU".

    
answered by 04.02.2014 в 12:23
32

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

This was invented because these 9 characters are not part of ISO 646 . Thus, to be able to program on any keyboard compatible with this standard, the trigraphs 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 in the compilation line.

  • link
  • answered by 04.02.2014 в 12:32