Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In c program Define a function called count _ lines _ with that counts how many lines in a file contain a certain keyword. The
In c program Define a function called countlineswith that counts how many lines in a file contain a certain keyword. The function should have two char parameters, one used to store the name of the file to search, and one used to store the search term. For example, given a file named systemlogtxt with the following content: STATUS door open COMMAND door close STATUS door close The function should give this output: countlineswithsystemlogtxt "STATUS" should return countlineswithsystemlogtxt "door" should return countlineswithsystemlogtxt "open" should return Hints: you will need fopen, feof, fgets and fclose to read the file, and strstr to search. Please note: you should not write a main function. Assume that all necessary #include statements, the main function, and the printf statements to display output have all been implemented. You should write only the countlineswith function.
In c program Define a function called countlineswith that counts how many lines in a file contain a certain keyword. The function should have two char parameters, one used to store the name of the file to search, and one used to store the search term.
For example, given a file named systemlogtxt with the following content:
STATUS door open
COMMAND door close
STATUS door close
The function should give this output:
countlineswithsystemlogtxt "STATUS" should return
countlineswithsystemlogtxt "door" should return
countlineswithsystemlogtxt "open" should return
Hints: you will need fopen, feof, fgets and fclose to read the file, and strstr to search.
Please note: you should not write a main function. Assume that all necessary #include statements, the main function, and the printf statements to display output have all been implemented. You should write only the countlineswith function.
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