#include<stdio.h>
#include<string.h>


char* my_strstr(const char* str1,const char* str2)
{

char *cur=(char*)str1;
char *p1=NULL;
char *p2=NULL;


if(*str1=='\0')
return (char*)str1;
while(*cur)
{
p1=cur;
p2=(char*)str2;

while(*p1!='\0' && *p2!='\0' && (*p1==*p2))
{
p1++;
p2++;
}
if(*p2=='\0')
return cur;
if(*p1=='\0')
return NULL;

cur++;

}
return NULL;//找不到子串
}
int main()
{
char *str1="abcdef";
char *str2="def";

char* ret=my_strstr(str1,str2);

if(ret==NULL)
{
printf("子串不存在\n");
}
else
{
printf("%s\n",ret);
}

}