Question: Ques) write a program in c, which meets the following requirements. Requirements 1. Write a program called contains that takes two text strings as arguments

Ques) write a program in c, which meets the following requirements.

Ques) write a program in c, which meets the following requirements. Requirements

Requirements 1. Write a program called "contains" that takes two text strings as arguments and prints "true" followed by a newline if the second string is entirely contained within the first, or "false" followed by a newline otherwise. 2. The strings contain only ASCII characters and may be any length> 0 characters. Strings in argv are always null-terminated This is an important problem in computer science, with wide applications from searching the internet, to understanding text, to finding DNA matches. It's easy to state and easy to code. It gets interesting when the strings are long and you want to do it very efficiently. For now you can be happy with a simple solution to practice managing argv array and char strings. Example runs: ./contains "I have a really bad feeling about this" "bad feeling" true $./contains "To be or not to be" "That is the question" false $ ./contains "I am the walrus" "I am the walrus" true $./contains "the walrus""I am the walrus" false ./contains "kmjnhbvc45& $bn" "." false 1 Notice that the strings do not have quote characters around them when delivered to your program via argv. The quotes prevent the shell from breaking the strings up into individual words. You may find the standard library function strlen() (along with other string-related functions) useful. Read its manpage. NOTE: pay attention to the requirements, e.g. don't forget the newlines

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!