#include
#include
#include
char *mystrstr(char *string,char *findstring )
{
if (string == NULL || findstring == NULL)
{
return NULL;
}
int flag = 1;
while (*string != '\0')
{
char *p=string;
char *px = string;
char *now = findstring;
while (*now != '\0')
{
if (*px == *now)
{
px++;
now++;
}
else
{
flag = 0;
break;
}
}
if (flag == 1)
{
return p;
}
string++;
}
if (flag == 0)
{
return NULL;
}
}
void main()
{
char str1[20] = "i love you";
char str2[20] = "love";
char *p=mystrstr(str1, str2);
if (p == NULL)
{
printf("没有找到\n");
}
else
{
printf("%c\n", *p);
}
system("pause");
}