Electrical and Computer Engineering
2 of 12
UAH
CPE 112
Working with Character Data
•Each computer uses a particular character set, two in substantial use today are ASCII and EBCDIC. The vast majority use ASCII.
•Character Issues:
–Comparing Characters: if (ch >= ‘a’ && ch <= ‘z’) – islower is preferred usage
–Converting Digit Characters to Integers: ‘9’ – ‘0’ = 9
–Converting to Lowercase and Uppercase: toupper and tolower can help (#include <cctype>)
– Accessing Characters Within a String: Use position number, e.g. ch = inputStr[2];
–