strstr库函数实现
#include<stdio.h>
#include<assert.h> char *strstr(char* src,char *sub)
{
if(src==NULL||NULL==sub)
{
return src;
} const char *bp=src;
const char *sp=sub; while(*src)
{
bp=src;
sp=sub;
do{
if(!*sp)
return src;
}while(*bp++==*sp++);
src+=;
} return NULL;
} int main()
{
char p[]="";
char q[]="";
char *r=strstr(p,q);
printf("r:%s\n",r); return ;
}
strstr库函数实现的更多相关文章
- 【c语言】模拟库函数strstr
// 模拟库函数strstr #include <stdio.h> #include <assert.h> const char* my_strstr(const char * ...
- C语言中库函数strstr的实现
在C语言中库函数strstr()函数表示在一个字符串str1中查找另一个字符串str2,如果查到则返回str2在str1中首次出现的位置,如果找不到则返回null. char* strstr(char ...
- C语言库函数strstr、strch比较
该库函数包含在<string.h>头文件中,函数原型:extern char *strstr(char *str1, const char *str2);使用方法 char *strstr ...
- C标准库函数实现之strstr(转)
看下Linux下的实现: char *strstr(const char *s1, const char *s2) { size_t l1, l2; l2 = strlen(s2); if (!l2) ...
- c语言,string库函数strstr实现
说明: 原型:char *strstr(char *haystack, char *needle); 用法:#include <string.h> 功能:从字符串haystack中寻找ne ...
- 库函数strstr的实现
没什么说的,常规思路: 函数原型:const char* StrStr(const char *str1, const char *str2) 方法一: str1:源字符串: str2:需要查找的目的 ...
- C库函数strstr分析
C标准库<string.h> 函数声明: char* strstr(char* const _String, char const* const _SubString) 返回值: SubS ...
- C 库函数 - strstr()
定义 char *strstr(const char *haystack, const char *needle) 参数 haystack -- 要被检索的 C 字符串. needle -- 在 ha ...
- C语言标准库函数(网络上copy的)
C语言标准库函数 标准io函数Standard C I/Oclearerr() clears errorsfclose() close a filefeof() true if at the end- ...
随机推荐
- 来自 Repository 的一丝线索,Domain Model 再重新设计
来自 Repository 的一丝线索,Domain Model 再重新设计 写在前面 阅读目录: 疑惑解读 设计窘境 一幅图的灵感 为嘛还是你-Repository 后记 上一篇<No zuo ...
- IOC 容器在 ASP.NET MVC 中的应用
IOC 容器在 ASP.NET MVC 中的应用 IOC:Inversion Of Control 翻译为控制反转,我们在面向对象软件开发过程中,一个应用程序它的底层结构可能由N种不同的构件来相互协作 ...
- Amazon前技术副总裁解剖完美技术面试
Amazon前技术副总裁解剖完美技术面试 投递人 itwriter 发布于 2014-03-03 14:30 评论(0) 有1729人阅读 原文链接 [收藏] « » 英文原文:The Anat ...
- ios中判断控制台Log输出控制,是否是iphone5,自动调整尺寸
// 控制台Log输出控制,此确保在release版本下无Log输出 #ifdef DEBUG #define CMBLOG NSLog #else #define CMBLOG ...
- 无穷字符串问题--CSDN上的面试题(原创)
网上看到一道奇怪的题,分享一下:http://hero.csdn.net/Question/Details?ID=307&ExamID=302 发布公司:CSDN 有 效 期:2014-02- ...
- JAVA实现数据库数据导入/导出到Excel(POI)
准备工作: 1.导入POI包:POI下载地址http://mirrors.tuna.tsinghua.edu.cn/apache/poi/release/src/(重要) 如下 2.导入Java界面美 ...
- Your personal Mail Server iRedMail on ubuntu14.04 x64
what we have? iRedMail -> http://iredmail.com Get the script over there. http://www.ired ...
- GIT 版本控制命令学习
一 基本命令 1.$ git init 要对现有的某个项目开始用 Git 管理,只需到此项目所在的目录,执行: 2.$ git status 检查当前文件状态 3.git add命令 功能1:可以 ...
- 读excel时候出现java内存溢出
修改Eclipse,或MyEclipse的内存 例如MyEclipse 在window->preferences->myeclipse->application server-> ...
- Trade-----HDU3401----单调队列优化的DP
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=3401 题目意思: 有T天,你每天可以以API买进,BPI卖出,最多买ASI个,最多卖BSI个 最多只能 ...