4.6 – Digraph characters in C language

by subbu on September 13, 2013

Digraph characters in C language:

In 1994 C standards supplied digraphs as more readable alternatives to five of the trigraph characters. Most of the compilers recognize these characters without giving any option to the compiler.

The digraph preprocessor replaces all the occurrences of digraph characters by their single character equivalents before any process.

Trigraph sequence

Digraph

Equal character

??=

% :

#

??(

< :

[

??)

:>

]

??<

<%

{

??>

%>

}

The simple Hello World program has to write using digraph characters as

%:include<stdio.h>
int main()
<%
printf("Hello\nWorld");
return 0;
%>

The digraph preprocessor changes the above code as

#include<stdio.h>
int main()
{
printf("Hello\nWorld");
return 0;
}

Note: Turbo C can’t execute ¬†C programs with digraph characters.

Previous post:

Next post: