-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathexec11-5.cpp
More file actions
35 lines (32 loc) · 811 Bytes
/
exec11-5.cpp
File metadata and controls
35 lines (32 loc) · 811 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <cctype>
#include <iostream>
#include <string>
using namespace std;
struct CharTypeFunction {
int (*pf)(int);
string name;
} char_types[] = {
{isspace, "whitespace"},
{isalpha, "alphabetic"},
{isdigit, "decimal digit"},
{isxdigit, "hexadecimal digit"},
{isupper, "uppercase letter"},
{islower, "lowercase letter"},
{isalnum, "alphanumeric"},
{iscntrl, "control character"},
{ispunct, "punctuation"},
{isprint, "printable"},
{isgraph, "graphical"}
};
// Output the classification of each character.
int main() {
char c;
while (cin.get(c)) {
cout << '\'' << c << "' is ";
for (const CharTypeFunction& f : char_types)
if (f.pf(c))
cout << f.name << ',';
cout << endl;
}
return 0;
}