2.4) Primitive Data Types of C++: Characters
Available types:
char
for basic 8-bit characters (latin alphabet)wchar_t
for 'wide' (16 or 32-bit) characters (not used in this course)
Note that char
and wchar_t
represent single characters, not strings of characters; C++ provides a separate string
type for that
Representation of literal values:
- Literal characters are enclosed in single quotes - e.g., 'x'
- Wide characters are indicated via an L prefix - e.g., L'X'
- Three-digit octal (base 8) character codes can be used, with \ as a prefix - e.g., '\167' is 'w', '\170' is 'x'
- Escape sequences exist to represent 'special' characters - for example, '\t' is a tab, '\n' is a newline