C++ Character Data Types

Advertisements
Advertisements

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

Advertisements

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.

signed char

The signed \hspace{3px} 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.

Bestseller

Let Us C++

One of the best selling book in C++ programming language. A perfect book for beginners and people who want to prefer self-study in step by step manner. Simple and easy narration style made this book very popular. The book assumes that you don’t have programming experience and starts with basic to more advanced topics.

Advertisements
Advertisements
Advertisements