A Cast of Characters

This should give you some idea of how numeric variables and values work. But what about nonnumeric ones?

This brings us to the subject of two new variable types and the values they can contain. These are the char (short for "character") and its relative, the string. What are these good for, and how do they work?[20]

[20] In case you were wondering, the most common pronunciation of char has an a like the a in "married", while the ch sounds like "k".

A variable of type char corresponds to 1 byte of storage. Since a byte has 8 bits, it can hold any of 256 (2^8) values; the exact values depend on whether it is signed or unsigned, as with the short variables we have seen before. Going strictly according to this description, you ...

Get Learning to Program in 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.