Print it ?? and!! in a different sequence, a different output will be displayed

I found a strange conclusion when I write the following lines in a very simple way:

the code:

 printf("LOL??!\n");
 printf("LOL!!?\n");

Conclusion: alt text

This happens even when compiling code in both MBCS and UNICODE.

The output depends on the sequence "?" and "!" ...

Any idea?

+5
source share
5 answers

You can try

printf( "What?\?!\n" );

In computer programming, digraphs and trigraphs are sequences of two and three characters that are interpreted as one character in a programming language.

. , . Borland , , , .

+5

??! trigraph, |.

, .

+16

??! - |.

C/++ . , , , .

# grepping in the source file:
$ grep printf a.c      
  printf("foo: ??!");

# grepping the preprocessor output:
$ gcc a.c -trigraphs -E | grep printf | grep foo
  printf("foo: |");
+5
source

The ??! called a trigraph and is replaced by | in conclusion. Check link

+4
source

This is a special sequence of characters in a string constant that has special meaning. Called the trigraph, they were originally implemented because not all terminals supported certain characters.

+2
source

All Articles