C++ Character Set

In this article, you will gain a basic understanding of the topic "character set in C++," along with an illustration of its use. Therefore, let's not waste any more time and get right down to its concise introduction.

Introduction to character sets

A character set is a collection of typographically correct symbols that are usable within a specific language. A letter, a digit, or any other sign can be represented by something called a character.

C++ has the following character set:

Above are the list of character set, which are used most of the time, specially the first two which are "letters" and "digits". However, C++ can process any of the 256 ASCII characters as data or as literals.

Note that the term "literals" refers to the character or group of characters (word) that is used to describe the value that is used in the program. Thank you for your attention to this matter. If the values that they store do not change, literals are also referred to as variables. To put it another way, literals are unable to be changed, whereas variables can. When referring to a value as mutable rather than immutable, we are able to make adjustments to it or bring it up to date.

C++ Character Set Example

The following C++ program will provide you with an example of how character sets can be used in the C++ programming language:

using namespace std;
int main()
   char letter, digit, special;

   cout<<"Enter a letter: ";
   cout<<"You entered a letter: "<<letter<<endl;

   cout<<"\nEnter a digit: ";
   cout<<"You entered a digit: "<<digit<<endl;

   cout<<"\nEnter a special character: ";
   cout<<"You entered a special character: "<<special<<endl;

   return 0;

Following is an example of the output that will be generated by the aforementioned C++ program when it is compiled and run:

C++ character set

Now supply the inputs one by one and hit the "ENTER" key. For example, type "c" as a letter and then hit the "ENTER" key; then type "3" as a digit and hit the "ENTER" key again; finally, type "]" as a special character and hit the "ENTER" key a third time. For your understanding, I included the following snapshot after doing the same.

c++ character set example

More Examples

Here are some C++ programs that you might enjoy:

C++ Quiz

« Previous Tutorial Next Tutorial »

Liked this post? Share it!