1. Engineering
  2. Computer Science
  3. exercise description write a search program called searchc that runs...

Question: exercise description write a search program called searchc that runs...

Question details

Exercise Description Write a search program called search.c that runs as follows ./search <input file> <threshold> 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 that there will only be lower case letters in the file. For example, given the foll owing input file, input.txt:cat mouse bat hat the following are three scenarios that would happen if you run your program nadieug12:> ./search input.txt 1 a appears 3 times t appears 3 times nadieug12:> ./search input.txt 0 a appears 3 times b appears 1 time c appears 1 time e appears 1 time h appears 1 time m appears 1 time o appears 1 time s appears 1 time t appears 3 times u appears 1 time nadieug12:> ./search input.txt There are no letters that exceed this threshold Your program must check that the correct number of 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 <input file> <threshold> Your program must check if the input file exists and exits otherwise. For example, running it with a file that does not exist should produce the following message to stderr: nadieug12:> ./search nonexistent_file.txt5 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 lettersYour program must contain a Makefile that compiles your program into an executable called search . Your program must compile without wanrings or errors. Your Makefile must have a clean target. Otherwise, you will get a O for this exercise. Hint: google the function atoi to see how you can treat the passed threshold as an integer.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution