#include <iostream>
using namespace std;
const char * myStrstr(const char * src, const char *sub_str)
{
for (int index = 0; src[index] != '\0'; index++)
{
int j = 0;
int temp = index;
if (src[index] == sub_str[j])
{
while (src[index++] == sub_str[j++])
{
if (sub_str[j] == '\0')
{
return &src[index - j];
}
}
index = temp;
}
}
return NULL;
}
int main()
{
char *strSrc = "123456789";
char *strSub = "34";
cout<<myStrstr(strSrc,strSub);
return 0;
}
strstr函数实现
最新推荐文章于 2019-12-06 15:37:09 发布
3378

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



