Write a C++ program called stats.cc
analyzes its standard input,
displaying a summary of what it read. It tells you how many control
characters it encountered, how many letters, how many numbers, etc.
                
Here are several sample runs, where %
is my prompt.
Your output must match exactly.
                
% g++ -Wall stats.cc % echo | ./a.out Control: 1 Letter: 0 Number: 0 Punctuation: 0 Symbol: 0 Space: 0 % echo 'Price: $42' | ./a.out Control: 1 Letter: 5 Number: 2 Punctuation: 1 Symbol: 1 Space: 1 % echo "According to horses, 2+2=10" | ./a.out Control: 1 Letter: 17 Number: 4 Punctuation: 1 Symbol: 2 Space: 3 % ./a.out <~cs253/pub/hamlet.txt Control: 10412 Letter: 136033 Number: 0 Punctuation: 8362 Symbol: 48 Space: 27713
How do I know which characters are what? For example, the distinction
between “Punctuation” and “Symbol” seems a bit arbitrary. Use the file
~cs253/pub/ASCII-properties
. It
contains 128 lines, like this:
                
00 Cc 01 Cc … 1E Cc 1F Cc 20 Zs 21 Po 22 Po 23 Po 24 Sc … 30 Nd 31 Nd 32 Nd … 40 Po 41 Lu 42 Lu …
The first field is the two-digit hexadecimal ASCII value of the character. The second field is a two-letter property. The first letter is:                 
The second letter is a finer description of the property. For example,
Lu
means “Letter, uppercase” and Sm
means “Symbol, math”.
Ignore the second character for this assignment
(vague sense of foreboding).
                
Your program may open that file during execution, or you may incorporate the information in that file into your program. You may not assume that a copy of that file is present in your current directory.                 
argv
. Read standard input, via cin
.
<stdio.h>
or <cstdio>
facilities,
such as printf
, scanf
, fopen
, and getchar
.
cin
, cout
,
and ifstream
.
stats.cc
.
If you have any questions about the requirements, ask. In the real world, your programming tasks will almost always be vague and incompletely specified. Same here.                 
Use web checkin, or Linux checkin:                 
~cs253/bin/checkin HW1 stats.cc
Turn in someone else’s work.                 
Modified: 2017-01-30T19:30                  User: Guest                  Check: HTML CSSEdit History Source |
Apply to CSU |
Contact CSU |
Disclaimer |
Equal Opportunity Colorado State University, Fort Collins, CO 80523 USA © 2015 Colorado State University |