浅谈指针—find_char(实现strpbrk函数)
来源:互联网 发布:十大域名注册商 编辑:程序博客网 时间:2024/05/17 23:03
/*
*函数原型:char* find_char(char const *source,char const *chars)
*函数功能:
* 如果source和chars为空,直接返回NULL;chars中的字符与source
* 中的字符不匹配也返回NULL;若匹配,则返回返回指向source中的第一
* 个匹配的位置的指针。
*/
#include<stdio.h> char* find_char(char const *source,char const *chars){char *a = source;char *b = chars;if(NULL == *a || NULL == *b){return NULL;}while((*a!= 0)){while((*b!= 0)) { if(*a == *b){ return (char*)a;} else { b++; }} b = chars; a++; }return NULL;}int main() { char str[] = "lifeishard"; char chars[] = "commeo"; char *p; p = find_char1(str,chars); printf("%s\n",p); return 0; }
结果:
0 0
- 浅谈指针—find_char(实现strpbrk函数)
- 指针_字符串搜索(find_char)
- 系统函数C字符串的实现(6):strpbrk
- 浅谈find_char()函数 字符串中找单个字符和多个字符
- strpbrk函数
- strpbrk() 函数
- strpbrk() 函数
- strpbrk() 函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk函数
- strpbrk 函数
- strpbrk函数
- strpbrk()函数
- JavaScript函数小结
- eclipse连接sql server 2008
- 利用map将“简写信件”转化为“原始信件”
- 数学高手看过来!!!
- 返回无符号整形的二进制数1的个数
- 浅谈指针—find_char(实现strpbrk函数)
- UVaOJ 401 - Palindromes
- 整数除法的取整方式
- 谈谈对handler,Looper,Message的android消息处理机制
- [Mac使用技巧]如何显示隐藏文件
- [2413]n a^o7 !
- activemq链接mysql
- Google的C++开源代码项目
- 级联下拉菜单