/* testchar1.cpp CIS 150 David Klick 6/30/05 Simple character functions. */ #include #include #include using std::cout; using std::setw; using std::boolalpha; int main(void) { char sample[] = "dD.\t7"; int i; // display heading cout << " alpha digit alnum space lower upper punct print\n" << " ----- ----- ----- ----- ----- ----- ----- -----\n"; // display information for each character in array for (i=0; i<5; i++) { if (isprint(sample[i])) cout << sample[i] << ":"; else cout << " :"; cout << boolalpha << setw(6) << (bool) isalpha(sample[i]) << setw(6) << (bool) isdigit(sample[i]) << setw(6) << (bool) isalnum(sample[i]) << setw(6) << (bool) isspace(sample[i]) << setw(6) << (bool) islower(sample[i]) << setw(6) << (bool) isupper(sample[i]) << setw(6) << (bool) ispunct(sample[i]) << setw(6) << (bool) isprint(sample[i]) << '\n'; } return 0; } /* Sample output: alpha digit alnum space lower upper punct print ----- ----- ----- ----- ----- ----- ----- ----- d: true false true false true false false true D: true false true false false true false true .: false false false false false false true true : false false false true false false false false 7: false true true false false false false true */