C++ Character Data Type

In C++, the char data type is used to store a single character. This could be a letter, number, or symbol, and it must be enclosed in single quotes (' ').

Tutorials dojo strip



Declaring a Character Variable

To define a character variable, use the char keyword and assign it a single character.

Example

C++




Using ASCII Values in char

Characters can also be represented using ASCII codes, which are numeric values corresponding to different characters.

Example

C++




Key Points About char in C++

  • A single character is enclosed in single quotes ('A').
  • char only stores one character, unlike string, which handles multiple.
  • ASCII values can be used to represent characters numerically.
Tutorials dojo strip