CS211b Assignment 5

Issued on: Tuesday 1:00am, March 20, 2007.
Due by: Monday midnight, April 9, 2007.


This assignment is to encourage you to do exercise on the dynamic data structure in C: the linked list , and on shell programming under UNIX. Since it will involve many important functions and commands, we will count it as two assignments. Therefore, it is our last assignment in this class and its total score is 20%.

Problem 1 (12%):

Write a program wordStat in C to do statistics on the words and the line numbers on which they appear in a text file. For example, given a text file named SonnetOftheMoon.txt, your program will generate the summary as in the output.txt by executing
wordStat < SonnetOftheMoon.txt.

Please notice that, the words are listed in ascending alphabetical order, and the line numbers are listed in ascending numerical order. All the words are converted to lower case for easy comparison. A line length can be defined to hold 255 chars.

The function readword.c is provided to you here for reading in a text file word by word from standard input until an end of file (EOF) is reached. Please refer to the comments for the detail usage.

*Note: You are required to use a Makefile and header file(s) for this program.

Problem 2 (8%):