CS 100 Project Three – Spring 2017

Project Overview: Ever wonder what is in a file? Ever wonder how many times each character actually occurs in the file? Probably not – most people never think of things like that. This program takes an input source and tells the user what characters that source contains. It does not worry about whitespace (spaces, tabs, newlines) but instead focuses on the printable characters. These include:
• 26 upper-case letters, A – Z and 26 lower-case letters, a – z and 10 digits, 0 – 9
• 32 special characters: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
This program reads from standard input until end-of-file. Once it hits end-of-file, it tells the user what characters it saw, ordered from the most-occurring character down to the characters that it did not see. As an example, if the user entered the input below (shown in red), the program generates the output shown in blue.
The Quick Brown Fox Jumps Over the Lazy Old Dog
123456789012345
the quick brown fox jumps over the lazy old dog

( ### ( @@ [ ] !! ) $ )

------------------------------------------------------------------------

105 characters

lowercase=67 and uppercase=9 and digit=15 and special=14


Characters occurring 8 times : o
Characters occurring 6 times : e
Characters occurring 4 times : h r u
Characters occurring 3 times : d l t #
Characters occurring 2 times : a c g i k m n p s v w x y z O 1 2 3 4 5 ! ( ) @
Characters occurring 1 times : b f j q B D F J L Q T 0 6 7 8 9 $ [ ]
Characters not found in the input : A C E G H I K M N P R S U V W X Y Z " % & ' *
+ , - . / : ; < = > ? \ ^ _ ` { | } ~
What You Need To Do
• Create a directory project3 on your machine. In that directory, create a file named contents.c
• In contents.c, write the code needed to find out what characters exist in the input. Make sure that you:
o Have a header block of comments that includes your name and a brief overview of the program.
o Read from standard input until you hit end-of-file
o Prints the expected output in a clear, legible format
• Hint #1: There are some good built-in character functions in ctype.h that make coding easier. Make sure
you understand the functions isdigit and isupper and islower and ispunct.
• Hint #2: You can use an array or arrays to count the number of times you see each printable character
(initialize each element to zero and increment a given location when you see that letter).
• To test your program with various inputs, you can redirect input so that it comes from a file instead of the keyboard. As an example, if you wanted to see what the contents of your contents.c file was, you would type the command ./a.out < contents.c (using a.exe instead of a.out in Windows)
To submit your program:
• On your local machine, compress your project3 directory into a single (compressed) zip file. To do this:
~ PC: Using Windows Explorer, right click on the project3 directory and select “Send To” and then
“Compressed (zipped) folder”
§ If you are using Cygwin, your directory is probably in c:/cybwin64/home/userid
§ If you are using Bash, it is probably in c:/Users/userid/AppData/Local/lxss/home/userid
~ Mac: Using Finder, use a secondary click on the project3 directory and select “Compress foldername”
• Once you have a compressed zip file named project3.zip, submit that file to Blackboard.