char constants denoted by single char within pair of single quotes:
'a' //lowercase letters 'W' //uppercase letters '$' //punctuation characters '9' //digit characters '8' is not 8 ' ' //blank (or space) character '\n' //newline escape sequence '\t' //tab '\\' //backslash'ab' is a syntax error, or should be...It won't work.
'a' is different than "a" char string char c1, c2; //char variables cin >> c1; //single char input. spaces and newlines skipped over c2 = c1; //assign char cout << c2: //output the char ... char c; cin >> c; if (c == 'y') cout << "It's a y";char has integer value as specified in ASCII table:
char again; ... cin >> again; if (again == 'y') //do some stufftoupper, tolower, isupper, islower etc. functions are in ANSI C++ cctype header file, so include it.
cin >> again; //variable again is not changed by the toupper function //returns the uppercase version of the value of again if (toupper(again) == 'Y') //allow either y or Y //do the same stuff ----------------------------- char low, up; cin >> low; up = toupper(low); //up is uppercase version of low ---------------------------- cin >> low; if (islower(low)) up = toupper(low); else cout << "Input is not a lowercase letter"; ---------------------------- char c; cin >> c; while (islower(c)) { cout << "Error. Must be non lowercase letter. " << "Reenter: "; cin >> c; } --------------------------- //error-checking loop to ensure that user enters valid data, here //meaning a lowercase letter: cin >> c; while (!islower(c)) {//logical Not operator, reverse truth value cout << "Error. Must be lowercase. Reenter: "; cin >> c; }Next (string)