Due: Fri, May 27, 11:59 PM (100 Points)
Objectives: Refresh C/C++ programming skills. Use C++ I/O streams, string class, and STL containers and algorithms. Use makefile to organize and compile programs.
Statement of Work: Implement a program that collects the statistics of word, number, and character usage in a file (redirected as the standard input).
Requirements:
Create a subdirectory called proj1.
For this project you need to create at least two files: proj1.cpp, and makefile. Both files should be placed in the proj1 directory.
The file
proj1.cpp should contain the main
function, int main(). In the main() function, the program should
read the input (from standard input) until it reaches the end, counting the number of times each
word, number, and character is used.
Output specifications:
An example executable code of the program is provided to you (see below). You should make the outputs of your program match this sample executable. When printing characters, use '\t' for tab and '\n' for newline. All other characters should be printed normally.
Write a makefile for your project that compiles an executable called proj1.x
You are encouraged to use any C++ STL containers and algorithms. You should also use C++ string class instead of default c-strings. Here are a few good reference links for library lookups:
Your program must be able to compile and run on linprog.
Example executable, some test cases
Download a set of 4 sample test files at this link. This is a tar file containing 4 test files (test0, test1, test2, test3). You will need to unpack this tar file in your project directory.
When you create your own executable, you'll need to re-direct any test files as the standard input to your program, like this:
proj1.x < test0The provided example executable can be run from linprog, at the location ~myers/dsprog/proj1.x . So, for example, you can run the same test file as in the example above with:
~myers/dsprog/proj1.x < test0
Submission
Tar all the source codes, including proj1.cpp and the makefile into a single tar
archive and submit online via blackboard, in the "Assignments" section. Use the Assignment 1 link
to submit.
Make sure you tar your programs correctly. You are
responsible for incorrect submissions (for example, empty tar file). You can
untar the file under a different
directory to make sure that you do include all the right source files. Same
late policy applies if the submission is incorrect and you need to submit a new
version.
Your tar file should be named in this format, all lowercase:
lastname_firstname_p1.tar Example: My tar file would be: myers_bob_p1.tar
Note that in addition to the provided test cases, we will also test your program using additional test files. Your program must be able to pass all the test cases in order to obtain a full score for the corresponding components.