Final answer:
To solve the assignment, create a character array as a working buffer and follow the steps to tokenize the input, count unique words, and print the report.
Step-by-step explanation:
Program for Listing Unique Words
To solve this assignment, you can follow the steps below:
-
- Create a character array as a working buffer to store the input characters.
-
- Read up to 2048 characters from stdin and store them in the buffer.
-
- Tokenize the input into words based on whitespace.
-
- Count the occurrence of each unique word and store the count along with the word itself.
-
- Print the report listing each unique word, its offset from the beginning of the input, and the count of occurrences.
Example:
If the input is 'I am having problems with my program. I hope you can help me.', the program should output:
Word | Offset | Count
---- | ------ | -----
I | 0 | 1
am | 2 | 1
having | 5 | 1
problems | 12 | 1
with | 21 | 1
my | 26 | 1
program | 29 | 2
hope | 37 | 1
you | 42 | 1
can | 46 | 1
help | 50 | 1
me | 55 | 1