Char / Character Data Type
How is "char" datatype used in C++?.
The "char" data type
is used to represent character or small integers. Mostly this datatype is used for ASCII codes. The signed range of the char datatype is between -128 to 127 and the unsigned range is between 0 to 255.
using namespace std;
char c = 'A';
cout << c << '\n';
cout << "Bytes used by char is:" << sizeof(c);
Bytes used by char is:1
In the above example a character "A" is declared using the char data type. Using the sizeof() function the number of bytes occupied by the datatype is also retreived.