#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
const char* StrStr(const char* find, const char* str)
{
assert(str != NULL && find != NULL);
while (str)
{
const char blue = str;
const char* red = find;
while (*blue != ‘\0’ && *red != ‘\0’&&*blue==*red)
{
blue++;
red++;
}
if (*red == ‘\0’)
return str;
if (blue == ‘\0’)
return NULL;
str++;
}
return NULL;
}
int main()
{
char str[] = “hellhelhellohellow”;
char find[] = “hellow”;
const char s = StrStr(find, str);
if (s == NULL)
printf(“不存在\n”);
else
printf("%s\n", s);
return 0;
}
Strstr
最新推荐文章于 2025-02-13 14:40:53 发布
2888

被折叠的 条评论
为什么被折叠?



