strpbrk 函数
来源:互联网 发布:日本电影 知乎 编辑:程序博客网 时间:2024/06/05 17:59
函数原型:char *strpbrk( const char *string, const char *strCharSet );wchar_t *wcspbrk( const wchar_t *string, const wchar_t *strCharSet );
函数原型:
char * strpbrk(const char * cs,const char * ct){const char *sc1,*sc2;for( sc1 = cs; *sc1 != '\0'; ++sc1) {for( sc2 = ct; *sc2 != '\0'; ++sc2) {if (*sc1 == *sc2)return (char *) sc1;}}return NULL;}
功能:依次检验字符串s1中的字符,当被检验字符在字符串s2中也包含时,则停止检验,并返回该字符位置,空字符NULL不包括在内。
说明:返回s1中第一个满足条件的字符的指针,如果没有匹配字符则返回空指针NULL。
用途:在源字符串(s1)中找出最先含有搜索字符串(s2)中任一字符的位置并返回,若找不到则返回空指针。
csdn:例子
/* STRPBRK.C */#include <string.h>#include <stdio.h>void main( void ){ char string[100] = "The 3 men and 2 boys ate 5 pigs\n"; char *result; /* Return pointer to first 'a' or 'b' in "string" */ printf( "1: %s\n", string ); result = strpbrk( string, "0123456789" ); printf( "2: %s\n", result++ ); result = strpbrk( result, "0123456789" ); printf( "3: %s\n", result++ ); result = strpbrk( result, "0123456789" ); printf( "4: %s\n", result );}
输出:
1: The 3 men and 2 boys ate 5 pigs
2: 3 men and 2 boys ate 5 pigs
3: 2 boys ate 5 pigs
4: 5 pigs
2: 3 men and 2 boys ate 5 pigs
3: 2 boys ate 5 pigs
4: 5 pigs
11 1
- strpbrk函数
- strpbrk() 函数
- strpbrk() 函数
- strpbrk() 函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk 函数
- strpbrk函数
- strpbrk()函数
- strpbrk函数
- strpbrk函数
- 字符串函数strpbrk
- 字符串函数strpbrk
- GDataXML解析XML
- 使用hql使用order by子句出现异常和数据异常的解决办法org.hibernate.hql.internal.ast.QuerySyntaxException
- 学习C语言要具备两种态度
- wikioi 1283 等差子序列(bitset 01位的巧妙使用)
- 最近很忙,现在很闲。。。
- strpbrk 函数
- C语言中->含义
- POJ 3278 简单广搜
- 二叉树遍历
- eclipse安装maven插件及从svn检出项目时没有check out as maven project选项解决方法
- emmc移植到flash需要修改的文件
- LINUX ulimit命令
- hdu 4105 Electric wave(dp)
- 4126313