-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcharacter-classification.cpp
More file actions
42 lines (40 loc) · 1.06 KB
/
Copy pathcharacter-classification.cpp
File metadata and controls
42 lines (40 loc) · 1.06 KB
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
36
37
38
39
40
41
42
#include <iostream>
#include <cctype>
#include <string>
#include <sstream>
std::string classification(char c)
{
std::string all_classification;
if(isspace(c)){all_classification+=" is space ";}
if(isalpha(c)){all_classification+= " is alpha ";}
if(isdigit(c)){all_classification+= " is digit ";}
if(isxdigit(c)){all_classification+= " is xdigit ";}
if(isupper(c)){all_classification+= " is uppercase ";}
if(islower(c)){all_classification+= " is lowercase ";}
if(isalnum(c)){all_classification+= " is alphanumeric ";}
if(iscntrl(c)){all_classification+= " is control character ";}
if(ispunct(c)){all_classification+= " is punctuation ";}
if(isprint(c)){all_classification+= " is printable ";}
//if(isgraph(c)){}
return all_classification;
}
void write(std::stringstream& ss)
{
std::string temp;
char ch;
while(ss.get(ch))
{
std::cout << ch << "(" << (int)ch << "): " << classification(ch) << '\n';
}
}
int main()
{
char ch;
std::stringstream buffer;
while(std::cin.get(ch))
{
buffer << ch;
}
write(buffer);
return 0;
}