首页 > 代码库 > 20140723 字符串包含程序

20140723 字符串包含程序

1、字符串包含程序
#include<stdio.h>#include<string.h>int Strstr(char *String, char *Substring){    if(String==NULL||Substring==NULL||strlen(String)<strlen(Substring))        return -1;    char *pString=String;    char *pSubstring=Substring;    int count=0;    while(*pString!=\0)    {        pSubstring=Substring;        while(*pSubstring==*pString)        {            pString++;            pSubstring++;            if(*pSubstring==\0)                return count;        }        pString++;        count++;    }}void main(){    char Str[]="ABCD";    char Substr[]="ABCDEEE";    int index=Strstr(Str,Substr);    printf("%d",index);}