C++ - 实现strstr函数
来源:互联网 发布:淘宝手写披露函 编辑:程序博客网 时间:2024/06/05 14:30
/*函数名: strstr功能:找出字符串str2在字符串str1中第一次出现的位置(不包括str2的串结束符)。返回值:若找到,返回指向该位置的指针;否则,返回空指针。*/#include <iostream>#define NULL 0using namespace std;char* myStrstr(const char* s1, const char* s2){if (*s2){while (*s1){for (int i = 0; *(s1 + i) == *(s2 + i); i++){if (!*(s2 + i + 1)){return (char*)s1;}}s1++;}return NULL;}else{return (char*)s1;}}int main(){char s1[20] = "453456789123456788";char s2[6] = "34567";char* s = myStrstr(s1, s2);cout << s << endl;return 0;}// Output:/*3456789123456788*/
- C实现strstr函数
- c/c++ strstr()函数实现
- c语言实现 strstr 函数
- c语言函数strstr()实现
- [C++]LeetCode 28: Implement strStr() (实现strStr()函数)
- C语言函数strstr()分析及实现
- 实现c语言strstr函数功能
- C 函数 strstr 的高效实现
- C 标准库 strstr 函数的实现
- 【C语言】模拟实现strstr函数
- C库中的strstr()函数实现
- c语言模拟实现strstr函数
- c/c++自己实现strstr函数
- C/C++ 用C语言实现strstr函数
- strstr()函数-C语言
- C语言strstr函数
- C语言 函数 strstr
- C-strstr函数
- eclipse+tomcat发布工程时修改8080端口为80时要注意的问题
- MAPIFolder.UserDefinedProperties 的作用
- 字符串练习:对字符串数组,按字典顺序排列大小
- myeclipse与eclipse利用tomcat发布web工程的区别
- onSaveInstanceState和onRestoreInstanceState触发的时机
- C++ - 实现strstr函数
- 无意看见的几句话
- typeid与typedef
- 基于逻辑表达式的集合运算
- Stanford机器学习---第三讲. 逻辑回归和过拟合问题的解决 logistic Regression & Regularization
- 字符串练习2:输出一个子串在整串中出现的次数
- 解决ubuntu下filezilla登录ftp看不到中文目录和文件的问题
- C++ - 实现strcmp函数
- 心态和想法,是提高编程水平的关键