The character data type is one of the primitive data types by C++ programming language. The character data type uses keyword char and it has a minimum size of 1-byte or 8-bits.
This is good enough to hold any ASCII characters because the values of characters in keyboard lies between 0 – 127. In other words, there are 128 characters.
Learn C++ programming basics before you begin with character data types.
There are many types of character data types in C++. See the list below.
- unsigned char
- signed char
The most common form usage is char and its size of 1-byte good enough to hold any machine’s basic character set. The char is the keyword.
The plain char is unsigned in most machines and its size if 8-bits. But, the values it can take ranges from 0 to 255.
The signed char is also of 8-bits and it takes positive as well as negative values. The range is from -127 to + 127. In some machines, it is -127 to +28.
This character data type can hold any character set which include not only the basic character set, but any extended character set of a system. The extended characters are wider than 8 bits and starts with L.
For example, L ‘c3’
char16_t and char32_t
The char16_t and char32_t is to represent the UTF-8 character sets which is any natural language.