Counting Letter and Word Occurences


I have a project due soon (which I usually begin very early), however I was unable to. I know this is last minute, but just seeing if anyone out there can help.

I need to write a program that first reads the contents of a text file of arbitrary length, and then collects the number of times each word appears in the file, as well as the number of times each letter appears.

I need to implement the following functions (parameters are not given):

1) bool load()
-------Opens file with given filename and reads the contents
-------If file cannot be read, return false
-------For each word read in, add it to the word list if it is not already in the list
-------If it is already in the word list, increase the counter for that word -------You should be able to use your find function to determine if the word is already known
-------Upon successfully reading in the contents of the file return true

2) int find()
-------Find the target string
-------Ask the user for the name of a file
-------Use the load function to load the file into memory.

3) void letterStats()
-------Determine how often each letter or symbol appears using the data loaded from the file, and stores the list of letters and frequencies in lexicographical order
-------Hint: keep in mind the number of times a given word has appeared

4) void alphabetize()
-------Alphabetize a list of words/letters and frequencies. Lexicographical order (using the > and < operators between strings) is considered alphabetized for the purposes of this project.
-------Once these functions are implemented, use them to count the letters loaded from the file, and print the results (both word and letters). Multiple occurances of a word/letter should be shown by indicationg the number of times the word/letter appeared, not by repeating the word/letter

5) void save()
-------This function should open an output file with the given filename -------Once the file is open, it should save the statistics to the file. -------Ask the user for a filename
-------Use the function to save the file

I have some definitions written out, but I think they are all very, very wrong. Any help at all would be GREATLY appreciated!!!
Try to give us an attempt. :)
Hope this helps.
closed account (9y8C5Di1)
Use dynamic memory to store each new word, and have a respective counter.
Topic archived. No new replies allowed.