Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Assume a file named words. txt exists. The file contains exactly 5 0 lines, and each line contains a single word. Some of the words
Assume a file named words. txt exists. The file contains exactly lines, and each line contains a single word. Some of the words appear only once in the file, but some of them appear two or more times. For this project, you will write a program that reads the contents of the file and counts the number of times each unique word appears in the file.
The program should use a structure that has two members:
A string to hold a word from the file
An int to hold the number of times the word appears in the file
The program should create an array of the structures and use the array to hold all the unique words from the file and the number of times each word appears. After the program has processed the contents of the file, it should step through the array and display each unique word from the file, followed by a space, followed by the number of times that word appears in the file.
Note: Your program should disregard case when processing the words from the file. For example, the words "eagle" and "EAGLE" should be considered equal.
The following sample run shows an example of the expected output of the program. In this sample run, the program found unique words in the file. The word "option" appears time, the word "eagle" appears time, the word "popular" appears times, and so on
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