Question
(c++)Write a program that reads in a text file a word at a time. The FIRST time that a word is encountered, store the word
(c++)Write a program that reads in a text file a word at a time.
The FIRST time that a word is encountered, store the word in a dynamically created array. DO NOT add a word more than one time.
Create a parallel, dynamic integer array to hold a count of the number of times that each particular word appeared in the text file. Be sure to increment the corresponding word frequency counter in the parallel integer array each time the word appears.
Different capitalization does NOT indicate a different word.
Be sure to remove any non-alpha characters from the beginning or ends of the words (internal non-alpha words are OK, such as non-alpha).
Create and use the following text file containing a quote from Albert Einstein to test your program:
The definition of insanity is doing the same thing over and over and expecting different results.
At the end of your program, generate a report that prints the contents of your two array in a format similar to the following:
Word: Frequency:
The 2
definition 1
of 1
insanity 1
over 2
and 2
Once your program works with the test file shown above, create or find a much bigger file and rerun your program to see if it still works correctly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started