strchr和strstr
2014-03-11 14:53
357 查看
最近在 复习C/C++部分知识,在准备着 招聘。。。。。
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/wail.gif)
char * strchr(char * str, int ch) :功能就是找出在字符串str中第一次出项字符ch的位置,找到就返回该字符位置的指针,如果找不到就返回空指针(就是 null)。
代码实现:
char str[20]="Hello world";
char c = 'o';
printf("%s\n",strchr(str,c));
输出结果:o world
char * strstr(char * str1,char * str2);功能就是找出在字符串str1中第一次出项字符串str2的位置(也就是说字符串sr1中要包含有字符串str2),如果找不到就返回空指针(就是 null)。
代码实例:
char str[20]="Hello world";
char c[4] = "el";
printf("%s\n",strstr(str,c));
输出结果:ello world
![](http://static.blog.csdn.net/xheditor/xheditor_emot/default/wail.gif)
char * strchr(char * str, int ch) :功能就是找出在字符串str中第一次出项字符ch的位置,找到就返回该字符位置的指针,如果找不到就返回空指针(就是 null)。
代码实现:
char str[20]="Hello world";
char c = 'o';
printf("%s\n",strchr(str,c));
输出结果:o world
char * strstr(char * str1,char * str2);功能就是找出在字符串str1中第一次出项字符串str2的位置(也就是说字符串sr1中要包含有字符串str2),如果找不到就返回空指针(就是 null)。
代码实例:
char str[20]="Hello world";
char c[4] = "el";
printf("%s\n",strstr(str,c));
输出结果:ello world
相关文章推荐
- c语言:strcpy、strncpy、 Strcat、 Strcmp 、strchr、 strstr、 Strlen等函数功能
- php使用strpos,strstr,strchr注意啦,若是数字查找则会当成ASCII码处理
- 模拟实现C库函数strcpy,strcat,strstr,strchr,strcmp,memcpy,memmove
- 模拟实现strchr,strrchr,strstr,strrstr函数
- 字符串函数模拟实现(strcpy,strcat,strstr,strchr,strcmp,memcpy,memmove)
- strchr strstr (判断 子字符(串))
- strstr strchr strrchr strrstr
- PHP字符串函数之 strstr stristr strchr strrchr
- strchr和strstr的用法
- C语言字符串处理的一些函数strok,strstr, strchr,strsub
- c 字符串、字符和字节 strlen、strcpy、strcat、strcmp、strchr、strstr
- C语言学习5:数组定义,数组名的含义,数组作为函数参数,数组赋值,数组左右移动,最大最小,反向遍历,冒泡排序,sizeof 和strlen区别,gets和puts,strcpy,strcat,strcmp,strchr,strstr,strlen
- 字符串/字符匹配:strstr()及strchr()函数
- c 字符串操作函数strtok、strstr、strchr备忘
- strstr()与strchr()、竖式问题
- strchr,strstr--字符串
- strchr strrchr strstr
- gets,strcmp,strcat,strchr,strstr的应用
- PHP字符串函数之 strstr stristr strchr strrchr
- 字符串函数---strstr()、memchr()、strchr()详解及实现