#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int judge(char* p,char find)
{
while (find)
{
if (p != find)
{
return 0;
}
p++;
find++;
}
return 1;
}
int strStr(char str, char find)
{
char p = str;
char q = find;
int count = 0;
while (*p!=’\0’)
{
if (*p == *q)
{
if (judge(p, find))
{
return count;
}
}
p++;
count++;
}
return -1;
}
int main(void)
{
char str[1024] = " “;
gets_s(str);
char find[1024] = " “;
gets_s(find);
int count=strStr(str,find);
printf(”%d\n”, count);
system(“pause”);
return 0;
}
实现strStr
最新推荐文章于 2022-03-26 12:46:44 发布