#define _CRT_SECURE_NO_WARNINGS 1 #include<stdio.h> #include<assert.h> #include<stdlib.h> char *my_strstr(char *arr1, char *arr2) { assert(arr1); assert(arr2); char *s1 = arr1; char *p = arr2; char *s2 = p; while (*s1 != '\0') { while ((*s1 != '\0') && (*s2 != '\0') && (*s1 == *s2)) { s1++; s2++; } if (*s2 == '\0') { return s1; } } return NULL; } int main() { char *arr1 = "abcdeff"; char *arr2 = "abc"; char *ret = my_strstr(arr1, arr2); printf("%s", ret); system("pause"); return 0; }