C/C++ Trigraphs and Digraphs

by Shabbir on May 19, 2008

in C/C++

Trigraph is a sequence of three characters. The first two always are question marks "??".
Trigraphs are equivalent to some single characters. Here is a table from trigraphs and their equivalents

Trigraph

Equivalent

??!

|

??<

{

??>

}

??/

\

??'

^

??-

~

??=

#

??(

[

??)

]

This can cause some problems for new programmers. See this example

  1. // This will be executed???????????/
  2. i++;

This line of code will not be executed, because is used a trigraph "??/" the compiler will not compile the line.

Digraphs are used for the same issues as the trigraphs, see the digraphs

Digraph

Equivalent

<:

[

:>

]

<%

{

%>

}

%:

#

%:%:

##

Sharing is Caring...

Leave a Comment

Previous post:

Next post:

    About the Author

  • author photo

    My Name is Shabbir Bhimani and I am developer by profession in the field of applications, web and database. Currently doing full time online marketing and like to share my experiences on how you can make money online @ CodeItWell.com. Read more ...


    See how you can get in touch with me.