#include<stdio.h>
#include<string.h>
#include<stdlib.h>
char *locatesubstr(char *str1, char *str2);
int main()
{
char str1[500], str2[500];
gets(str1);
gets(str2);
char *p = NULL;
p = locatesubstr(str1, str2);
if(p==NULL)
printf("NULL!\n");
else{
while (*p != '\0')
printf("%c", *p++);
printf("\n");
}
return 0;
}
char *locatesubstr(char *str1, char *str2)
{
int i;
if (*str2 != '\0')
{
while (*str1 != '\0')
{
for (i = 0; *(str1 + i) == *(str2 + i); i++)
{
if (*(str2 + i + 1 )== '\0')//ÅжÏstr2µÄÏÂÒ»¸ö×Ö·ûÊÇ·ñΪ'\0'£¬ÇмǴø *
return (char*)str1;
}
str1++;
}
return NULL;
}
else
return (char*)str1;
}