Question: Can you please help me answer this question using POINTERS Thanks!! Question 9: (30 points) Implement the function to take in a 10-character string 'string'1'
Question 9: (30 points) Implement the function to take in a 10-character string 'string'1' and 3-character pattern string 'pattern' from the user- Search for the 'pattern' in 'stringl' and display "pattern found" if 'pattern' is found in stringl'. For instance, if user enters string1= "abcdefghij" and pattern- "ghi", then the pattern exists in stringi, so display "pattern found". Do not display anyhting if pattern is not found in stringl You MUST use pointers and not arrays for this question. You may use string functions You may not add more variables than already declared. You may use 'int i' for 'for' loop, if needed. Note :When using fgets0), when you press Enter to finish entering the string, the Enter (In) character is also added to the string. So a 10-character string actually looks like "abcdefghijlnle". So consider storing 12 elements for 10-character string. void searchPattern() char *string1, pattern; int string!Len-0, patternLen = 0; // while(getchar() !. .); // Enter your code here // use this line to get rid of In left behind by scanf and similar functions in code above Output nter the 10-character string which needs to be searched for a pattern: quizmaster ter the 3 character pattern to search: ast
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
