Question
Complete the program substring.c provided as boilerplate code to you. The boilerplate code specifies what the program needs to do. Program is compiled in C.
Complete the program substring.c provided as boilerplate code to you. The boilerplate code specifies what the program needs to do. Program is compiled in C.
#includeint main(int argc, char **argv) { const int BUF_LEN = 128; char haystack[BUF_LEN]; char needle[BUF_LEN]; char c; int i, j, substring, found; int needle_len, haystack_len; /* Get the user to enter two strings */ printf("Please enter a string, finishing the entry by pressing Enter. "); for (i=0; i Input/Output Examples:
$ ./substring Please enter a string, finishing the entry by pressing Enter. apple Please enter another string, finishing the entry by pressing Enter. applestrudle The strings you entered are "apple" and "applestrudle". "apple" is contained as a substring in "applestrudle". $ ./substring Please enter a string, finishing the entry by pressing Enter. adam Please enter another string, finishing the entry by pressing Enter. Madame Bovary The strings you entered are "adam" and "Madame Bovary". "adam" is contained as a substring in "Madame Bovary". $ ./substring Please enter a string, finishing the entry by pressing Enter.
Please enter another string, finishing the entry by pressing Enter. banana The strings you entered are "" and "banana". "" is contained as a substring in "banana". $ ./substring Please enter a string, finishing the entry by pressing Enter. banana Please enter another string, finishing the entry by pressing Enter. banana The strings you entered are "banana" and "banana". "banana" is contained as a substring in "banana". $ ./substring Please enter a string, finishing the entry by pressing Enter. oranje Please enter another string, finishing the entry by pressing Enter. Goranje The strings you entered are "oranje" and "Goranje". "oranje" is contained as a substring in "Goranje". $ ./substring Please enter a string, finishing the entry by pressing Enter. orange Please enter another string, finishing the entry by pressing Enter. Goranje The strings you entered are "orange" and "Goranje". "orange" is not contained as a substring in "Goranje".
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