I was going through few interview questions and I came across example as below. I tried the example for simple input/output and also for some logic and it works without any problems.
??=include <stdio.h>
int main(void)
??<
printf("Hello");
// Other code lines here
return 0;
??>
To my surprise, this worked without any compilation issue and output was as required.
What is the significance of '??=', '??<' and '??>' here ?
What is the significance of '??=', '??<' and '??>' here ?
??=
will be replaced with #
,
??<
will be replaced with {
,
??>
will be replaced with }
,
by the preprocessor. These are called trigraphs. There are 9 trigraphs in total; the others are:
??(
will be replaced with [
,
??)
will be replaced with ]
,
??/
will be replaced with \
,
??'
will be replaced with ^
,
??!
will be replaced with |
,
??-
will be replaced with ~
.
Trigraphs are processed very early in the translation process, before the source code is tokenized. They can affect comments and strings and character literals.