Homework Assignment 3; CS 450

Part 1: Try test files and report running time and most common word

Try all the files in the testFiles directory. Report running times (also where you ran them) and the most common word in a file HW2_TESTING.

You can use "time" to do this. At the command prompt, for example, "time grep foo file" will report the time to run grep. See "man time".

Note: 30 copies of these would be bad in the homework directories :-) Please do not turn in copies of these! If you have ones we should add, let me know - thanks!

Part 2: Cleanup

Replace data structures if necessary. Remember the requirements given in homework 2 that your solution should process even large files quickly. Linked lists are not ok.

Respond to the grader's comments from HW1 and 2 in HW3_LOG.

Add a "make clean" target to your makefile if you haven't already.

Fix bugs.

Part 3: Actively assess your own code

1. Step through code in Gdb

Step through your code in a debugger, like gdb. Record a stack trace from within one of your more deeply nested functions. Put this in a file HW3_LOG.

2. Test error handling ability

Test your code's error handling ability. For example, ask it to count the words in a file that does not exist and an empty file. Give it a variety of command line options that it is not prepared to handle. Ask it to count the words in a binary file. Does your program exit gracefully under all conditions and report output for even unusual files.

If you do not already, check the return code of functions like malloc and fopen.

The goal is for your program to fail gracefully on any input. If you discover that it does not, make an entry in the BUG_LOG and modify your program so that it does.

Describe the testing you did in your HW3_LOG.

3)Add assertions to your code which test conditions you believe to the true. (Use the assert function in assert.h). Everyone must add at least 5. Yes this is a somewhat arbitrary limit!

4)Identify the line or lines of code that allocate memory for each distinct word found. Say specifically what will happen if you run out of memory. How will the error be reported?

Part 4: Allow user to pipe in input file.

Users want the ability to pipe a file into the program. For example, "cat input_file | program". This means that you will need to handle both an input file and an stdin.

Part 5: Submit your assignment.

Submit updated versions of all of your code including the CHANGE_LOG, HW3_LOG and updated time tracking information.