Character types

The most basic type in C and C++ is the following character type:

#include <iostream>int main(void){    char c = 0x42;    std::cout << c << '\n';}// > g++ scratchpad.cpp; ./a.out// B

A char is an integer type that, on most platforms, is 8 bits in size, and must be capable of taking on the value range of [0, 255] for unsigned, and [-127, 127] for signed. The difference between a char and the other integer types is that a char has a special meaning, corresponding with the American Standard Code for Information Interchange (ASCII). In the preceding example, the uppercase letter B is represented by the 8-bit value 0x42. It should be noted that although a char can be used to simply represent an 8-bit integer type, its default meaning ...

Get Hands-On System Programming with C++ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.