The Simulation library function strstr () function//from the parent string (longer) found exactly the same substring (shorter);//Returns the address of the first character of the same string in the parent string; #include <stdio.h >char * my_strstr (char arr[],char arr1[]) {char *p1=null,*p2=null,*p=null;int I = 0,j = 0,k=0,m=0;p1 =&arr[0];p 2 = &arr1[0];while (1) {if (arr1[0] == ') {printf ("The valid length of the sub-array is incorrect! \ n "); return null;} if (*p2== ') break; i++;p 2++;} while (1) {if (arr[0] == ') {printf ("The valid length of the parent array is incorrect! \ n "); return null;} if (*p1== ') break;j++;p 1++;} if (i > j) {printf ("The word group is larger than the parent array! Unable to query! \ n "); return null;} P1 =&arr[0];p 2 = &arr1[0];j=0;while (1) {if (*P1&NBSP;==&NBSP;*P2) {p = p1;p1++;p 2++;m=0;k++;} Else{p1++;j++;if (m==0) {m=1;k=0;p2=&arr1[0];}} if (k == i) return p-k+1;if (p1 == null | | p2 == null| | *p1== ' + ')break;} return null;} Int main () {char arr[20] = "0";char arr1[20] = "0";char* p = null;printf ("Please enter a string within 20 characters:"), gets (arr);p rintf ("Please enter a substring of the query:"), gets (arr1);p = my_strstr (arr, ARR1);if (p == null) {printf ("Your input has a problem or failed to find!") \ n ");} Else printf ("The first element of the substring in the parent string address is:%p\n", p);p rintf ("arr array first element address is (self-counting):%p\n", &arr[0]); return 0;}
C Language Simulation library function strstr () function