模拟实现库函数strstr
代码如下

#include<stdio.h>
const char* mystrstr(const char*src, const char *needle)
{

for (int i = 0; src[i] != '\0'; i++)
{
int temp = i;
int j = 0;
while (src[i] == needle[j])
{
i++;
j++;
if (needle[j] == '\0')
{
return &needle[temp];
}

}
i = temp;
}
return NULL;
}
int main()
{
char arr[] = "aaaaabcdaaa";
char brr[] = "abdc";
const char *s=mystrstr(arr, brr);
printf("%s", s);
system("pause");
}