C++ Character Data Types

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.

Advertisements

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 total 128 characters in ASCII character set.

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.

  1. char
  2. unsigned char
  3. signed char
  4. wchar_t
  5. char16_t
  6. char32_t

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.

unsigned char

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.

Advertisements

signed char

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 +128.

wchar_t

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.

Advertisements

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!!!

We have detected that you are using extensions to block ads. Please support us by disabling these ads blocker.