C Programming Character Literals
Last modified by Microchip on 2023/11/10 10:59
Rules
- Must be surrounded by single quotes (').
- May include any single printable character (e.g. 'a').
- May include any single non-printable character using escape sequences, also called diagraphs (e.g. '\0' for NUL).
Examples of Valid Character Literals
'a' | 'T' | '\n' | '5' | '@' | ' ' (space) |
Examples of Invalid Character Literals
'me' | '23' | ''' |
Because the single quote (') is used to delimit character literals, the single quote cannot by itself be a character literal. It must be specified using an escape sequence: '\''.