C/C++ string库(string.h)提供了几个字符串查找函数,如下:

memchr 在指定内存里定位给定字符
strchr 在指定字符串里定位给定字符
strcspn 返回在字符串str1里找到字符串str2里的任意一个字符之前已查找的字符数量
strrchr 在字符串里定位给定字符最后一次出现的位置
strpbrk 在字符串str1里定位字符串str2里任意一个首次出现的字符
strspn 返回字符串str1从开始字符到第一个不在str2中的字符个数
strstr 在字符串str1中定位字符串str2首次出现的位置 函数说明: 、memchr 原型:const void * memchr ( const void * ptr, int value, size_t num); void * memchr ( void * ptr, int value, size_t num); 参数:ptr,待查找的内存指针; value,要查找的值; num,内存大小。 说明:在ptr指向的内存中查找value,返回指向和value首次匹配的元素指针,如果没有找到,返回NULL指针。 、strchr 原型:const char * strchr ( const char * str, int character); char * strchr ( char * str, int character); 参数:str,待查找字符串指针; character,要查找的值。 说明:在字符串str中查找character,返回指向和character首次匹配的元素指针,如果没有找到,返回NULL指针。 、strcspn 原型:size_t strcspn ( const char * str1, const char * str2); 参数:str1,待查找的字符串指针; str2,要查找的字符串指针。 说明:在str1中查找str2中的字符,返回找到str2中任意一个字符时已查找的字符个数。 、strrchr 原型:const char * strrchr ( const char * str, int character); char * strrchr ( char * str, int character); 参数:str,待查找的字符串指针; character,要查找的值。 说明:在str中查找character,返回指向与character最后一次匹配的元素的指针,如果没有找到,返回NULL指针。 、strpbrk 原型:const char * strpbrk (const char * str1, const char * str2); char * strpbrk ( char * str1, const char * str2); 参数:在str1中查找str2中任意一个字符,返回指向与首次出现的str2中的任意一个字符匹配的元素的指针,如果没有找到,返回NULL指针。 、strspn 原型:size_t strspn ( const char * str1, const char * str2); 参数:str1,待查找的字符串指针; str2,要查找的字符串指针。 说明:从str1的第一个字符开始算起,直到出现一个不在str2中的字符为止,返回字符个数。 、strstr 原型:const char * strstr ( const char * str1, cosnt char *str2); char * strstr ( char * str1, const char * str2); 参数:str1,待查找的字符串指针; str2,要查找的字符串指针。 说明:在str1中查找匹配str2的子串,并返回指向首次匹配时的第一个元素指针。如果没有找到,返回NULL指针。

http://blog.csdn.net/isgray/article/details/6853700

C/C++字符串查找函数 <转>的更多相关文章

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

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

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

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

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

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

  4. 字符串查找函数(BF)

    //模拟字符串定位函数 // s: abcbbghi // t: ghi // 返回6 #include <iostream> #include <string> #inclu ...

  5. 字符串查找函数 find()函数

    find()函数可以帮助你在两个字符串之间,查找很多他们的关系... #include<iostream> #include<string> using namespace s ...

  6. c++ 字符串查找函数

    头文件:#include <string.h> 定义函数:int strcasecmp (const char *s1, const char *s2); 函数说明:strcasecmp( ...

  7. Lua 字符串查找函数 string.find(s, pattern [, init [, plain]] )【转】

    函数原型 string.find(s, pattern [, init [, plain]] ) s: 源字符串 pattern: 待搜索模式串 init: 可选, 起始位置 plain: 我没用过 ...

  8. 浅析JavaScript的字符串查找函数:indexOf和search

    语法 ①indexOf:方法可返回某个指定的字符串值在长字符串中首次出现的位置.如果被查找字符串没有找到,返回-1. indexOf 说明:该方法将从头到尾地检索字符串 stringObject,看它 ...

  9. 【pyhon】Python里的字符串查找函数find和java,js里的indexOf相似,找到返回序号,找不到返回-1

    # 例子: target='www.163.com' ')) ')==-1: print('263不存在于字符串'+target+'中') 运行: C:\Users\horn1\Desktop\pyt ...

随机推荐

  1. 解决 git 错误 error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 11

    环境 Windows 7 . git push 时出现错误,无法提交代码到远程仓库. Counting objects: , done. Delta compression using up to t ...

  2. python3 升级 pip9.0.1 到pip-9.0.3

    首先试试 python -m pip install --upgrade pip python3.5 升级 pip-9.0.3报错 You are using pip version 9.0.1, h ...

  3. Tomcat 运行 idea 编译好的 .class JavaWeb 项目

    对于新手来说,对于项目部署,有时候就是以为拷贝在idea控制台里面跑的项目放到tomcat里面的webapps里面跑就可以了,这仅仅限于静态项目..... 他不像PHP , 修改源码直接可以跑, 而J ...

  4. redis在mac中的安装和启动

    http://blog.csdn.net/chenshuai1993/article/details/51519384 http://www.jianshu.com/p/6b5eca8d908b

  5. openresty 几个插件使用

    1. jwt    opm get SkyLothar/lua-resty-jwt   2. cookie   opm get p0pr0ck5/lua-resty-cookie   3. http ...

  6. POJ2503:Babelfish

    浅谈\(Trie\):https://www.cnblogs.com/AKMer/p/10444829.html 题目传送门:http://poj.org/problem?id=2503 \(Trie ...

  7. ABP学习之路

    ABP文档介绍 http://www.cnblogs.com/kid1412/p/AbpDocumentContent.html [ABP开源项目]--vue+vuex+vue-router+EF的权 ...

  8. xunsearch安装及环境检测(一)

    1.运行执行下载解压安装包wget http://www.xunsearch.com/download/xunsearch-full-latest.tar.bz2解压到指定目录 tar -xjf xu ...

  9. JAVA Debug 调试代码

    JAVA Debug 调试代码 1.什么时候使用Debug: 程序的运行结果,与你的预期结果不同时,Debug的目的是找错误,而不是该错误: 2.早期调试代码的方式就是打桩: System.out.p ...

  10. C# 操作iis6、iis7 301

    iis6版本方法... iis7以及以上版本方法  using (ServerManager serverManager = new ServerManager())         {        ...