Answered step by step
Verified Expert Solution
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.
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
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