#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. grails的插件

    今天来歪理邪说一下grails的插件. 有个问题让本人困惑了一段时间,插件是属于grails的,还是属于某个工程的?为什么会有这个问题呢,这涉及到grails插件的安装方式. grails的插件像是一 ...

  2. js中的异常处理try...catch使用介绍

    在JavaScript可以使用try...catch来进行异常处理. 例如: try { foo.bar();} catch (e) { alert(e.name + ": " + ...

  3. php mysqli多个查询的例子

    php中Mysqli多个查询的例子,感兴趣的朋友可以参考下. php中Mysqli多个查询的例子,感兴趣的朋友可以参考下. mysqli_multi_query(mysqli link,string ...

  4. Kakfa揭秘 Day6 Consumer源码解密

    Kakfa揭秘 Day6 Consumer源码解密 今天主要分析下Consumer是怎么来工作的,今天主要是例子出发,对整个过程进行刨析. 简单例子 Example中Consumer.java是一个简 ...

  5. DOM初涉

    document documentURI, URL 返回当前网页的URL(String) activeElement 返回当前得到焦点的标签,input, textarea等比较常见,否则返回body ...

  6. (转)《深入理解java虚拟机》学习笔记5——Java Class类文件结构

    Java语言从诞生之时就宣称一次编写,到处运行的跨平台特性,其实现原理是源码文件并没有直接编译成机器指令,而是编译成Java虚拟机可以识别和运行的字节码文件(Class类文件,*.class),字节码 ...

  7. 十一、mysql输入安全

    .尽量使用“绑定参数”功能,php中可用pdo进行一系列操作 .php可使用mysql_real_escape_string()函数进行输入过滤:

  8. C# asp Aspose.Cells 教程,包含增加勾选框,单元格,字体设置

    1,引用Aspose.Cells  dll 2,using Aspose.Cells; 3, Workbook excel = new Workbook(); string strFilePath = ...

  9. IOS调用相机相册

    #import "SendViewController.h"  //只能打开,没有加载图片的代码,老代码,供参考 #import <MobileCoreServices/UT ...

  10. NOSQL Mongo入门学习笔记 - MongoDB的安装(一)

    手上的工作不是很忙,所以来学习学习很久就像接触的MongoDb,无奈前段时间工作时间都比较多.记录在这里供以后参考 环境: Centos 7 64位 开始: 1. 在官网下载Mongo : wget  ...