Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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.

The strings contain only ASCII characters and may be any length > 0 characters. Strings in argv are always null-terminated.

image text in transcribed

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 the strings contain only ASCII characters and may be any length > 0 characters. Strings in rag 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 rag 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&A$bn" "." false Notice that the strings do not have quote characters around them when delivered to your program via rag. The quotes prevent the shell from breaking the strings up into individual words. You may find the standard library function stolen () useful Read its manage

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

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

Students also viewed these Databases questions

Question

What is the function of osteoclasts and why are they needed?

Answered: 1 week ago

Question

What is the environment we are trying to create?

Answered: 1 week ago