char *mystrstr(char *s, char *t)
16 {
17 if (NULL == s || NULL == t) {
18 printf("please input right string!/n");
19 return NULL;
20 }
21
22 char *s_temp; /*the s_temp point to the s*/
23 char *m_temp; /*the mv_tmp used to move in the loop*/
24 char *t_temp; /*point to the pattern string*/
25
26 s_temp = s;
27
28 /*s_temp point to the s string*/
29 for (; *s_temp != '/0'; s_temp++) {
30
31 /*the move_tmp used for pattern loop*/
32 m_temp = s_temp;
33
34 /*the pattern string loop from head every time*/
35 for (t_temp = t; *t_temp == *m_temp; t_temp++, m_temp++)
36 ;
37
38 /*if at the tail of the pattern string return s_tmp*/
39 if (*t_temp == '/0') {
40 return s_temp;
41 }
42 }
43 }
16 {
17 if (NULL == s || NULL == t) {
18 printf("please input right string!/n");
19 return NULL;
20 }
21
22 char *s_temp; /*the s_temp point to the s*/
23 char *m_temp; /*the mv_tmp used to move in the loop*/
24 char *t_temp; /*point to the pattern string*/
25
26 s_temp = s;
27
28 /*s_temp point to the s string*/
29 for (; *s_temp != '/0'; s_temp++) {
30
31 /*the move_tmp used for pattern loop*/
32 m_temp = s_temp;
33
34 /*the pattern string loop from head every time*/
35 for (t_temp = t; *t_temp == *m_temp; t_temp++, m_temp++)
36 ;
37
38 /*if at the tail of the pattern string return s_tmp*/
39 if (*t_temp == '/0') {
40 return s_temp;
41 }
42 }
43 }