For the academic side, look at rici's well documented answer.
For the common sense side, unless you are already quite proficient in C, digraphs and trigraphs are completely useless, and you should not even waste any time on the subject. They were invented as a way to support non-US 7-bit characters sets that were still used in the 1980s on mainframes and some minicomputers. These character sets lacked some of the punctuation needed for the C language, such as #
, {
, }
etc. to make space for locale specific characters such as ç
, é
, è
... (pardon my French).
Even on these systems, which I used for a long while, trigraphs were never used, because ugly pragmatic alternatives existed: on French systems, accented letters such as é
and è
were typed but would be interpreted by the C compiler as {
and }
. It made C programming obscure and pushed many programmers to switch to a US QWERTY keyboard and Locale (or equivalent).
This is a thing of the past, only of historical interest and you will never see these in action, aside from typos, obfuscation and obnoxious interview questions.
Regarding the latter, I cannot resist posting this one:
I cannot get fnmatch
to validate my date template even if I force a valid date, what is wrong with this code:
#include <stdio.h>
#include <fnmatch.h>
int main() {
char date[] = "01/01/1988";
if (fnmatch("??/??/????", date, 0))
printf("invalid date format\n");
return 0;
}