Question: Consider the following code. char *findSubstring(char *str, char *needle) { int len = strlen(needle); int n = 0; while (*str) { printf(%c%c ,*str, *needle); if
Consider the following code.
char *findSubstring(char *str, char *needle) { int len = strlen(needle); int n = 0; while (*str) { printf("%c%c ",*str, *needle); if ( *(needle+n) == *str) { n++; if (n == len) return (str-len)+1; } else { str -= n; n = 0; } str++; } return NULL; }
What is the output of findSubstring("ABCDE","CD")?
Group of answer choices
AC BC CC DD
AC BC CC DC
AC BC CC DC EC
AC BC CC DC ED
AC BC CC
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
