9 ms·
They are alternative ways of writing the same character, unlike escape sequences, which have a different meaning from the unescaped version of the same characte
by klodolph 8y ago
They are alternative ways of writing the same character, unlike escape sequences, which have a different meaning from the unescaped version of the same character.
For example, in C, I can write:
int a<:10:>;
Or I can write:
int a[10];
They are the same, because <: is exactly the same as [, and :> is exactly the same as ] (except… mercifully, digraphs are not interpreted in strings; trigraphs are another story). However, in a string, the escape sequence \" means something different from ". One is a character in the string, the other ends the string.
Digraphs and trigraphs exist because not all keyboards have the corresponding characters, like [ and ]. For example, look at a Swedish keyboard. (You can type [ and ], but not as easily, and maybe not at all on some older keyboards.)