#include <string.h>
#include <stdio.h> char * string_search(char long_str[], char short_str[])
{//author: emanlee
char *pl, *qs;
long is_identical, long_length, short_length;
long position, ii; long_length=strlen(long_str);
short_length=strlen(short_str); if (long_length<short_length)
{
printf("ERROR\n");
return NULL;
} for (position=; position<long_length-short_length+; position++)
{
pl=long_str+position;
qs=short_str;
is_identical=; for (ii=; ii<short_length; ii++)
{
if (*pl != *qs)
{
is_identical=;
break;
} pl++;
qs++;
} if (is_identical==)
{
return long_str+position;
} } return NULL; } char * string_search_postion(char long_str[], char short_str[], long start_position)
{//author: emanlee
char *pl, *qs;
long is_identical, long_length, short_length;
long position, ii; long_length=strlen(long_str);
short_length=strlen(short_str); if (long_length<short_length)
{
printf("ERROR\n");
return NULL;
} for (position=start_position; position<long_length-short_length+; position++)
{
pl=long_str+position;
qs=short_str;
is_identical=; for (ii=; ii<short_length; ii++)
{
if (*pl != *qs)
{
is_identical=;
break;
} pl++;
qs++;
} if (is_identical==)
{
return long_str+position;
} } return NULL; } char * string_search_pointer_postion(char long_str[], char short_str[], char * start_position)
{//author: emanlee
char *pl, *qs;
long is_identical, long_length, short_length;
long position, ii; long_length=strlen(long_str);
short_length=strlen(short_str); if (long_length<short_length)
{
printf("ERROR\n");
return NULL;
} for (position=(long)(start_position-long_str); position<long_length-short_length+; position++)
{
pl=long_str+position;
qs=short_str;
is_identical=; for (ii=; ii<short_length; ii++)
{
if (*pl != *qs)
{
is_identical=;
break;
} pl++;
qs++;
} if (is_identical==)
{
return long_str+position;
} } return NULL; } void main()
{
char a[]="";
char b[]="";
char *p; p=string_search(a,b); printf("%s\n", string_search(a,b));
printf("%s\n", string_search_postion(a,b,));
printf("%s\n", string_search_pointer_postion(a,b,p+)); }

C语言字符串查找函数的更多相关文章

  1. 转:C语言字符串操作函数 - strcpy、strcmp、strcat、反转、回文

    转自:C语言字符串操作函数 - strcpy.strcmp.strcat.反转.回文 C++常用库函数atoi,itoa,strcpy,strcmp的实现 作者:jcsu C语言字符串操作函数 1. ...

  2. php中常用的字符串查找函数strstr()、strpos()实例解释

    string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] ) 1.$haystack被查找的字 ...

  3. C/C++字符串查找函数

    C/C++ string库(string.h)提供了几个字符串查找函数,如下: memchr 在指定内存里定位给定字符 strchr 在指定字符串里定位给定字符 strcspn 返回在字符串str1里 ...

  4. Strsafe.h:更安全的C语言字符串处理函数

    原文出处:Strsafe.h: Safer String Handling in C 作者:Michael Howard 编译:王凌峰 在微软公司举行的Microsoft Windows Securi ...

  5. C/C++字符串查找函数 <转>

    C/C++ string库(string.h)提供了几个字符串查找函数,如下: memchr 在指定内存里定位给定字符 strchr 在指定字符串里定位给定字符 strcspn 返回在字符串str1里 ...

  6. C语言字符串操作函数 - strcpy、strcmp、strcat、反转、回文

    原文:http://www.cnblogs.com/JCSU/articles/1305401.html C语言字符串操作函数 1. 字符串反转 - strRev2. 字符串复制 - strcpy3. ...

  7. php字符串查找函数 php查找字符串中出现的次数函数substr_count,判断字符串中是否包含另一个字符串函数strpos

    php字符串查找函数 php查找字符串中出现的次数函数substr_count,判断字符串中是否包含另一个字符串函数strpossubstr_count($haystack, $needle [,$o ...

  8. C语言字符串操作函数整理

    整理C语言字符串相关的函数,以程序方式验证,以注释方式做说明. #include<stdio.h> #include<string.h> #include<stdlib. ...

  9. C语言字符串处理函数

    函数名: strcpy  功  能: 拷贝一个字符串到另一个  用  法: char *stpcpy(char *destin, char *source);  程序例:  #include < ...

随机推荐

  1. DTCMS一些问题

    站点管理,主站和手机站同时绑定不同域名 手机站会报错,解决方法为 主站不绑定 手机站绑定 关键问题为:不能和主站域名相同 PC模版文件下的JS文件夹下的commen.js和手机模版下的JS文件夹下的b ...

  2. MAC机中安装RUBY环境

    在安装CocoaPods之前要先配置好RUBY环境,本文就怎么安装RUBY的环境进行一总结.安装Ruby环境首先需要安装Xcode然后需要安装Homebrew,接下来需要安装RVM最后安装Ruby环境 ...

  3. (转载)直接用SQL语句把DBF导入SQLServer

    告诉大家一个直接用SQL语句把DBF导入SQLServer,以及txt导入Access的方法,大家抛弃BatchMove吧来自:碧血剑告诉你一个最快的方法,用SQLServer连接DBF在SQLSer ...

  4. Python-Day1 Python基础学习

    一.Python3.5.X安装 1.Windows Windows上找度娘搜索“Python for windows下载”就OK了,安装的时候可以勾选设置环境变量,也可以安装完手动设置,这样在cmd中 ...

  5. orcale同一条语句运行速度差异问题

    在oracle中执行一个查询语句,该语句首次执行时orcale会把其内容存入SGA(系统全局区)中,下次再执行同一条语句的时候就不再去解析该语句,而是直接从SGA区中取出该语句执行,但是前提是SQL没 ...

  6. 浅析 public static void main(String[] args)

    最初接触Java程序的时候,老师就教导我们要从下面这句开始学起,据说是约定俗成的,所以直到今天,还是只知道java程序应该这么写,具体为什么这么写,鄙人惭愧. public class ClassNa ...

  7. shapefile文件

    基本信息编辑 ESRI公司的Shapefile文件是描述空间数据的几何和属性特征的非拓扑实体矢量数据结构的一种格式. 内容编辑 一个Shapefile文件最少包括三个文件: 主文件(*.shp).-- ...

  8. EF4.1之复杂类型

    首先我们生成两张对应表: public class Client { public int ClientID { set; get; } public string ClientName { set; ...

  9. 在系统方法中调用navigationController的标准写法

    在系统方法中调用navigationController的标准写法 -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animat ...

  10. C#正则表达式Regex类

    C#正则表达式Regex类的使用 C#中为正则表达式的使用提供了非常强大的功能,这就是Regex类.这个包包含于System.Text.RegularExpressions命名空间下面,而这个命名空间 ...