No “Hello World” but there is an “Eh?” example in the C ISO/IEC 9899:2011

Eh? You say.  No “Hello World” example in the C specification?  Yes, Surf4Fun says you are right!  But there is an “Eh?” printf example.

In paragraph page 23, Example 2, the C-specification has the following:

EXAMPLE 2 The following source line
becomes (after replacement of the trigraph sequence ??/)

This is not the trivial example of “Hello World”, but in the case of C the “Eh?” is used to demonstrate the use of Trigraph Sequences.  Which if you are experiencing a trigraph for the first time, let me discuss that for a few sentences…

What is this Trigraph thing?  So if you have not seen Trigraphs before, the example might be a little confusing.  The three question marks followed by the “back” slash, becomes “Eh?\n” because two question marks followed by a back slash then becomes the forward slash without the two questions marks.  Why the two question marks followed by a symbol suddenly changed to something else.  Weird right?  If you look up the word trigraph you will run across the military use of trigraphs, Central Intelligence Agency and encryption.  But in this case trigraphs are used to insert characters that are not on some keyboards.

You might be thinking, what keyboard doesn’t have “\” on it?  Well once upon a time, keyboards came in many configurations, and some of these keyboards only had capital letters, so everyone looked like they were shouting.  In fact this could bring us to the character set specifications, but I won’t go there, seriously there is Unicode, ANSI Character set and the evil ISO 2022 which uses a 7-bit encoding for the character sets.  (Ok, here are the free ECMA equivalent: ECMA-43: 8-bit, ECMA-6: 7-bit and the ECMA-35 is pretty indepth on how the character code set is designed.

Of course, you should be familiar with UNICODE, not ANSI Character set.  But saying that, knowing the ANSI character set will aid you in understanding some of the seemingly odd, non-printing characters like “bell”, decimal 07 or “EOT”, decimal 04.  The “Bell” code will actually generate a beep on your computer if you put it into a printing out term.

For a table of ANSI characters see:

So if you are using a keyboard that doesn’t contain one of the supported trigraph characters, then you need a new keyboard, but if you insist on using it, then here is the table for trigraphs from:

Key combination                 Character

??=  becomes        #

??(  becomes         [

??) becomes          ]

??/ becomes          \

??' becomes           ^

??< becomes         {

??> becomes          }

??! becomes          |

??- becomes          ~

Comments (0)

Skip to main content