Question: A C++ program that will dynamically resize a word structure array that stores the frequency of words found in a file named pa2-book.txt. The array

A C++ program that will dynamically resize a word structure array that stores the frequency of words found in a file named "pa2-book.txt". The array of word(s) should start with enough space to store 2 words and double each time more space is required.

struct word { char str[20]; int frequency; };

A word will be defined as a sequence of characters separated with whitespace or a combination of punctuation and a space. Our words will be case insensitive. So, make sure that all characters are changed to lowercase before entering them into your array. After counting the frequency of words located in the file, the array should be ordered alphabetically. Then, you need to display the contents of the word array followed by the size (number of elements) of your word structure array. You may not use any of the cstring or string libraries. If you desire to use a function from one of these libraries, you must write your own version. You can use the functions found in the ctype library like isspace(), ispunct(), and tolower().

Note: You will want to read your input file one character at a time and build your words. In other words, in this assignment you won't need to use >> operator for reading.

Sample File:

pa2-book.txt

This is a simple test. Test more thoroughly than this.

Sample Output:

is 1

more 1

should 1

simple 1

test 2

than 1

this 2

thoroughly 1

you 1

array size: 16

Thanks.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!