-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcctypes.cpp
More file actions
44 lines (40 loc) · 837 Bytes
/
Copy pathcctypes.cpp
File metadata and controls
44 lines (40 loc) · 837 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
36
37
38
39
40
41
42
43
44
#include <iostream>
#include <cctype>
using namespace std;
int main(int argc, char *argv[])
{
std::cout << "Enter text for analysis, and type @ to terminate input." << std::endl;
char ch;
int whitespace = 0;
int digits = 0;
int chars = 0;
int punct = 0;
int others = 0;
cin.get(ch);
while(ch != '@')
{
if(isalpha(ch))
{
chars++;
}
else if(isspace(ch))
{
whitespace++;
}
else if(isdigit(ch))
{
punct++;
}
else
{
others++;
}
cin.get(ch);
}
std::cout << chars << " letters, "
<< whitespace << " spaces,"
<< punct << " punct,"
<< others << " others"
<< std::endl;
return 0;
}