Why when the ON or OFF mode of strict compliance with ANSI C program produces different results? Compliance with strict about writing of the reasons that most modern industrial compilers default to some expansion of its own language, and some by default is C99, etc.
#include <stdio.h>
#include <string.h>
int main (void)
{
int len;
len = strlen ("??=");
printf ("len=%d\n", len);
return 0;
}
Here is the result. In both cases submitted compiler option -w to suppress warnings:
$ gcc t.c -w
$ ./a.out
len=3
$ gcc t.c -ansi -w
$ ./a.out
len=1
When it is not in ansi mode
gccis not converting the trigrpah??=(length 3) to#(length 1) which explains the length difference.If you had not suppressed warnings
gccwould warn that it is ignoring the trigraph in the non ansi mode(see it live):You can read more about dialect options in the Options Controlling C Dialect section of the
gccdocs. It says the following for-ansi:Trigraphs are covered in the draft C99 standard section
5.2.1.1Trigraph sequences which says:and the following sequences include: