e a C function with th rFindSimilar(char str n two strings str1 an lar" to str2. Two strin

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 17PE
icon
Related questions
Question
This is not a graded question so please don't disregard it as if it is.Thank you in advance professor! Note: This should be coded in c and NOT c++
Write a C function with the following prototype:
int strFindSimilar(char str1[], char str2[1]);
Given two strings str1 and str2, the function searches in str1 for the first occurrence of a substring
"similar" to str2. Two strings are considered "similar" if:
they have the same length
the number of corresponding characters of the two strings that are equal to each other
is more than half the length of str2
(that is, >strlen(str2)/2)
If such substring exists, the function returns the index of its initial character in str1. Otherwise, the
function returns -1.
Example of execution:
strFindSimilar("FifthOfNovember", "September")returns 6 because the substring
"fNovember", that starts at character 6, has 5 characters in common with the string
"September";
strFindSimilar("Seventh", "September") returns -1.
Transcribed Image Text:Write a C function with the following prototype: int strFindSimilar(char str1[], char str2[1]); Given two strings str1 and str2, the function searches in str1 for the first occurrence of a substring "similar" to str2. Two strings are considered "similar" if: they have the same length the number of corresponding characters of the two strings that are equal to each other is more than half the length of str2 (that is, >strlen(str2)/2) If such substring exists, the function returns the index of its initial character in str1. Otherwise, the function returns -1. Example of execution: strFindSimilar("FifthOfNovember", "September")returns 6 because the substring "fNovember", that starts at character 6, has 5 characters in common with the string "September"; strFindSimilar("Seventh", "September") returns -1.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Structure chart
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning