【C语言】模拟实现strtsr函数
来源:互联网 发布:sql语句update where 编辑:程序博客网 时间:2024/05/16 05:54
//模拟实现strtsr函数#include<stdio.h>#include<windows.h>#include<assert.h>char* my_strstr(const char*dststr, const char*substr);int main(){ printf("%s\n", my_strstr("abcdhellojihhello", "hello")); system("pause"); return 0;}char *my_strstr(const char*dststr, const char*substr){ assert(dststr); assert(substr); if (strlen(dststr) < strlen(substr)) { return NULL; } const char*dst_start = dststr; const char*sub_start = substr; const char*dst_end = dst_start + strlen(dststr) - strlen(substr); while (dst_start <= dst_end) { char *pos = dst_start; while (*sub_start != '\0'&&*dst_start == *sub_start) { dst_start++; sub_start++; } if (*sub_start == '\0') { return pos; } else { sub_start = substr; dst_start = pos + 1; } } return NULL;}
0 0
- 【C语言】模拟实现strtsr函数
- 【C语言】模拟实现库函数srtcpy函数
- 【C语言】模拟实现库函数strcat函数
- 【c语言】模拟实现库函数strcpy函数
- 【c语言】 模拟实现库函数strcat函数
- 【C语言】模拟实现strcmp函数
- 模拟实现C语言中的字符串函数
- C语言模拟实现memcpy,memmove函数
- C语言模拟实现memset.memcmp函数
- 【C语言】模拟实现strstr函数
- C语言::模拟实现strlen函数
- C语言::模拟实现strcat函数
- C语言,模拟实现strcpy、strlen函数
- c语言模拟实现strcpy函数
- c语言模拟实现strstr函数
- String函数的模拟实现(c语言)
- 【C语言】模拟实现strcpy()、strncpy()函数
- 【c语言】模拟实现strcat()、strncat()函数
- java集合类概述(学习笔记)
- NDK配置常见错误及解决
- tomcat系列-04-启用APR
- Re0模板系列: Floyd最短路
- Linux远程管理-SSH、VNC
- 【C语言】模拟实现strtsr函数
- Redis入门系列(二)NoSql的数据库的CAP原理+Base
- 对apk签名的封装
- python 库pandas的一些介绍
- SecureCRT作为客户端连接Linux服务器
- Longest Increasing Subsequence
- EETI eGTouch Linux 驱动的安装与使用
- SlidingMenu改造-增加当前滑动百分比的监听
- 【PMP】Head First PMP 学习笔记 第三章 过程框架