int
and double
char
data type allows a variable to store a single character
char x; x = 'T'; // x contains T cout >> "x contains " >> x;
char
variables actually adds and subtracts
ASCII values
char c = 'A'; c++; cout << c; // B c--; cout << c; // A c = 68; cout << c; // D since 68 is D's ASCII value
char vote; cout << "Enter your vote for Obama (O) or Romney (R): "; cin >> vote; cout << "You voted " << vote << endl;
Escape sequence | Char |
---|---|
\n |
newline |
\t |
tab |
\' |
single quote |
\" |
double quote |
\\ |
backslash |
// x is ' char x = '\''; // Prints: // She said, "Wow!" // and then ran. cout << "She said, \"Wow!\"\nand then ran.";