字符串查找strstr个人实现
2010-08-19 11:58
176 查看
=========================strstr个人实现=============================
char *Strstr(char *strSrc, const char *strDes) { int i, j; int lenSrc = 0, lenDes = 0; const char *pSrc = strSrc, *pDes = strDes; if ( strSrc == NULL || strDes == NULL ) return NULL; while ( *pSrc++ ) lenSrc++; while ( *pDes++ ) lenDes++; i = j = 0; while ( i < lenSrc && j < lenDes ) { if ( strSrc[ i ] == strDes[ j ] ) { i++; j++; } else { i = i - j + 1; j = 0; } } if ( j >= lenDes ) return &strSrc[ i - j ]; return NULL; }
相关文章推荐
- C/C++库函数strstr和find实现子字符串查找
- C/C++库函数strstr和find实现子字符串查找
- 模拟实现字符串查找函数strstr
- C语言:模拟实现字符串中查找一个字符串my_strstr()函数
- LeetCode OJ:Implement strStr()(实现子字符串查找)
- 一个自己实现的strstr 字符串查找函数,大家看看有什么错误和改进的地方
- leetcode | Implement strStr() | 实现字符串查找函数
- java查找字符串中的包含子字符串的个数实现代码
- C字符串操作:查找字符串函数strstr()
- KMP算法 C#实现 字符串查找简单实现
- 使用MFC中自带的CFindReplaceDialog类实现字符串查找和替换
- ACM/ICPC 常用函数---strstr()字符串查找函数
- Python 字符串操作实现代码(截取/替换/查找/分割)
- 查找字符串(C++实现)
- 模拟实现在一个字符串中查找一个字符串
- C 语言 字符串命令 strstr()的用法 实现将原字符串以分割串分割输出
- 实现字符串查找库函数
- strstr查找字符串, strch查找字符 (在字符串中) [Microsoft Corporation]
- java实现在指定目录中查找字符串
- java字符串位置查找的代码实现