#include
int SubString(char* LongString,char* ShortString);
int main(void)
{
char LS[] = "aabcdbcd";
char SS[] = "bcd";
// int num = SubString(LS,SS);
printf("%d\n",SubString(LS,SS));
return 0;
}
int SubString(char* LongString,char* ShortString)
{
int num=0;
char* p = ShortString;
// int len = sizeof(ShortString);//sizeof是运算符,不是函数,所以没有头文件
do
{
if((*(LongString++)) == (*(ShortString++)))
{
if((*ShortString) == '\0')
{
num++;
ShortString = p;
}
}
else
ShortString = p;
}while((*(LongString))!='\0');
return num;
}
阅读(1246) | 评论(0) | 转发(0) |