Search code examples
ctrigraphs

Print ?? and !! in different sequence will show different output


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

Code:

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

Output: alt text

It happens even the code is compiled under both MBCS and UNICODE.

The output varies on the sequence of "?" and "!"...

Any idea?


Solution

  • You may try

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

    In computer programming, digraphs and trigraphs are sequences of two and three characters respectively which are interpreted as one character by the programming language.

    Some compilers support an option to turn recognition of trigraphs off, or disable trigraphs by default and require an option to turn them on. Some can issue warnings when they encounter trigraphs in source files. Borland supplied a separate program, the trigraph preprocessor, to be used only when trigraph processing is desired.