Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C program to search a character in the lines Write a C program which takes a string arguement and a character arguement. It should return

C program to search a character in the lines

Write a C program which takes a string arguement and a character arguement. It should return turth value ( int 0 or 1) ,0 if string doesnot contain character and 1 if the string contains character. Donot use built in library for this .You should call this function and its variables whatever you consider appropriate.

The main function of the program should accept a single character followed by Enter. Then, it will read lines until the end of input (EOF). It should pass these lines to the function you wrote. If the character is in the line, it should print "FOUND: " and then the full line. If the character is not in the line, it should print "NOT FOUND: " and then the line.

Also, make sure that your program can accept an arbitrary number of lines of input. Either 5, 10, 90, or 1000 lines of input can be given after the first character and it should still work as intended even if you gave the program more input. Again, signal the EOF with CTRL+D. You should only need one buffer. Please use fgets .

if (fgets(buffer, 1000, stdin)) { /* line of input successfully read */ } else { /* end of input (EOF) reached or error */

Example Input

a Hello , Man ! Hi, Man!

Output >

FOUND: Hello, Man! NOT FOUND: Hi, Man!

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions