C and C++ – Why Are There Digraphs?

c++c99digraphslanguage-design

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?

Best Answer

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