The C Character Set – part 4.

The C Character Set – part 4.



play-rounded-fill play-rounded-outline play-sharp-fill play-sharp-outline
pause-sharp-outline pause-sharp-fill pause-rounded-outline pause-rounded-fill
00:00

Here’s Part 4 of an overview of the C character set, assuming you’re continuing a breakdown of the C programming language’s fundamental elements. If you’d like this to match a previous format or style, feel free to share that.


Contents [hide]

The C Character Set – Part 4: Trigraphs and Digraphs

🔹 What are Trigraphs?

Trigraphs are sequences of three characters that represent a single character not easily available on some keyboards. Although rarely used today, they are part of the C standard for backward compatibility with older systems.

Trigraph Sequences

Trigraph Replaces Description
??= # Hash / Pound sign
??/ \ Backslash
??' ^ Caret
??( [ Left square bracket
??) ] Right square bracket
??! ` `
??< { Left curly brace
??> } Right curly brace
??- ~ Tilde

📌 Example:

c
??=include <stdio.h> // Equivalent to #include <stdio.h>

🛑 Warning: Trigraphs are considered obsolete and can confuse readers. Most compilers disable them by default or issue warnings.


🔹 What are Digraphs?

Digraphs are two-character sequences that provide alternate ways to write some punctuation characters, particularly useful on systems where those characters are difficult to type.

Digraph Sequences

Digraph Replaces Description
<: [ Left square bracket
:> ] Right square bracket
<% { Left curly brace
%> } Right curly brace
%: # Hash / Pound sign

📌 Example:

c
<% int arr<:3:> = <%1, 2, 3%>; %> // Equivalent to: int arr[3] = {1, 2, 3};

🧠 Note: Unlike trigraphs, digraphs are more accepted but still uncommon in modern codebases.


🔹 Summary

  • Trigraphs: Deprecated and rarely used; composed of ?? followed by a third character.

  • Digraphs: Two-character alternatives for braces, brackets, and the hash sign; supported but rarely necessary.

  • Modern usage: Most modern systems and editors support all characters directly. These constructs mainly exist for compatibility.


Would you like Part 5 to cover character classification (e.g., letters, digits, etc.), or something else like escape sequences, keywords, or operators?

The C Character Set – part 4.

The C programming Language



Leave a Reply

Your email address will not be published. Required fields are marked *

error: