Why are there digraphs in C and C++?

Sydius picture Sydius · Jan 11, 2009 · Viewed 11.5k times · Source

I learned today that there are digraphs in C99 and C++. The following is a valid program:

%:include <stdio.h>

%:ifndef BUFSIZE
 %:define BUFSIZE  512
%:endif

void copy(char d<::>, const char s<::>, int len)
<%
    while (len-- >= 0)
    <%
        d<:len:> = s<:len:>;
    %>
%>

My question is: why do they exist?

Answer

CTT picture CTT · Jan 11, 2009

Digraphs were created for programmers that didn't have a keyboard which supported the ISO 646 character set.

http://en.wikipedia.org/wiki/C_trigraph