Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Exercise Description Write a search program called search.c that runs as follows ./search Your program reads the given text file input_file, which contains a string

image text in transcribed

image text in transcribed

Exercise Description Write a search program called search.c that runs as follows ./search Your program reads the given text file input_file, which contains a string on each line, and displays the characters that occur more than a given threshold . You can assume the following: (1) there will be only one word on each line, (2) the word will contain only lower case letters, and (3) the word will have at most 10 letters. For example, given the following input file, input.txt : cat mouse bat hat the following are three scenarios that would happen if you run your program: nadiug12:-> /search input.txt 1 a appears 3 times t appears 3 times nadi@ug12:-> ./search input.txt 0 a appears 3 times b appears i time c appears i time e appears i time h appears i time m appears i time o appears i time s appears i time t appears 3 times u appears i time nadi@ug12:-> . /search input.txt 3 There are no letters that exceed this threshold Your program must check that the correct number of program arguments has been passed. For example, running the program with a missing argument should produce the following message to stderr : nadi@ug12:-> ./search input.txt Usage: /search Your program must check if the input file exists. If the input file does not exist, the program must exit. For example, running the program with a file that does not exist should produce the following message to stderr : nadi@ug12:-> ./search nonexistent_file.txt 5 Error: cannot find nonexistent_file.txt Your program must also close the file stream before exiting. Your program must use an array to store the frequency of the letters of the alphabet. You can safely assume that you need to only handle 26 lower-case letters. Your program must contain a Makefile that compiles your program into an executable called search. Your program must compile without warnings or errors. Your Makefile must have a clean target. Otherwise, you will get a 0 for this exercise. Hint: google the function atoi to see how you can treat the passed threshold as an integer

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

Students also viewed these Databases questions

Question

4. Balancing Risks and Rewards with Expatriates

Answered: 1 week ago

Question

=+1 Where are the best places in the world to live (and work)?

Answered: 1 week ago

Question

=+Are you interested in working on global teams?

Answered: 1 week ago

Question

=+Do you want to work from home?

Answered: 1 week ago