Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use the two user define function in picture thanks!!!! Problem 1 (35 points): grep We wish to create a utility that will search a

please use the two user define function in picture thanks!!!!image text in transcribedimage text in transcribedimage text in transcribed

Problem 1 (35 points): grep We wish to create a utility that will search a text file for a specified string. Unix has a command line utility that does this called grep, which is a funny acronym that stands for globally search a regular expression andprint Write a C program that will search a text file for a specified string. Your program should a) Prompt the user for the name of the file to be searched b) Prompt the user for the string to be found in the file c) Print the name of the file searched d) If the string is found then print the entire line of text where the string was found and the line number e) Print the number of times the string was found ssumptions for this assignme Assume that all strings have a maximum length of 200 characters Assume that each line of the file being searched is no more than 200 characters long. Assume case sensitivity For example, if the file being searched contains OK and the string to find is ok then a match is not found; i.e. you do not need to worry about changing uppercase characters to lowercase or vice versa. . Here is some help to get you started reminder that fopen can take a variable argument: printf(" Enter a file name: In"); gets(fname); fp fopen(fname, "r"); A function that you might find useful is: void my_strcpy(char In], char Out, int L) nt 1, for(i = 0; 1

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions