Character set and Trigraph Characters in C

Every Program Instructions must conform precisely to the syntax rules of the language. C has its own vocabulary and grammar. They help to create different programs for different purposes.

Character set and Trigraph Characters

Character set

Every programming language contains a set of characters used to construct logic, statements, etc. In the C program, we can find a set of characters to create different programs. The characters in C are grouped into different categories which are,
  1. Letters
  2. Digits
  3. Special Characters
  4. White Spaces

Letters: Uppercase A to Z, lowercase a to z.

Digits: All decimal digits (0…9)

Special Characters:
Symbol
Name
Symbol
Name
,
Comma
#
Number sign (Hash, pound)
;
Semicolon
&
Ampersand
.
Period
^
Caret
:
Colon
*
Asterisk
apostrophe
-
Minus sign
?
Question mark
+
Plus sign
Quotation mark
(
Left parenthesis
|
Vertical bar (Pipe)
)
Right parenthesis
!
Exclamation mark
[
Left bracket
/
Slash (Forward slash)
]
Right bracket
\
Backslash
{
Left brace
%
Percent sign
}
Right brace
$
Dollar sign
< 
Opening angle bracket
~
Tilde
> 
Closing angle bracket
_
Underscore



White Spaces: Blank space, Newline, Horizontal tab, Carriage return, Form feed.

Trigraph Characters

There are many non-English keyboards. Many of these kinds of keyboards do not support some characters. ANSI C introduces the concept of the ‘trigraph’ sequence to provide a way to enter unavailable characters on some keywords. Suppose you have a no-English low-quality keyboard. You need to use the tilde symbol in your program but your keyboard doesn’t contain it. So, what you can do?
You can copy the tilde symbol from the internet or any kind of document or you can use trigraph character. To write tilde we have to type ??- 
Here are some ANSI C Trigraph Sequences:

Trigraph Sequence

Translation
??(
[ Left bracket
??)
] Right bracket
??<
{ Left brace
??>
} Right brace
??=
# Number sign
??!
| Vertical bar
??/
\ Backslash
??’
^ Caret
??-
~ Tiled
Post a Comment (0)
Previous Post Next Post