Trigraphs in C++


The ISO-646 character set does not have all the characters of the C syntax, therefore there are some systems with keyboards and displays that cannot deal with some characters. These characters can be constructed using a sequence of 3 characters called trigraphs. In C, before any other processing takes place, each occurrence of one of the following sequences of three characters (“trigraph sequences”) is replaced by the single character.

trigraph
replacement
trigraph
replacement
trigraph
replacement
??=
#
??(
[
??<
{
??/
\
??)
]
??>
}
??’
ˆ
??!
|
??-
˜


They are there mostly for historical reasons. Nowadays, most modern keyboards for most languages allow access to all those characters, but this used to be a problem once with some European keyboards. This is why trigraphs were invented.

Updated on: 30-Jul-2019

177 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements