一、strchr
1、表头文件
#include<string.h>
2、定义函数
char *strchr(const char *s,int c);
3、函数说明
strchr()用来找出参数s字符串中第一个出现的参数c的地址,然后将该字符出现的地址返回
4、返回值
找到指定字符返回该字符地址,否则返回0
5、eg
#include<stdio.h>
#include<string.h>
int main()
{
char src[100] = "hello world";
char *result = strchr(src,'o');
printf("result = %s\n",result);//输出o world
return 0;
}
二、strrchr
函数说明
找出参数s字符串中最后一个出现的参数c的地址,然后将该字符出现的地址返回
三、strpbrk
函数说明
找出参数s字符串中最先出现存在参数accept字符串中的任意字符
eg
#include<stdio.h>
int main()
{
char *s = "01234567890123456789";
char *p;
p = strpbrk{s,"a1 839"};//1最先在s中找到
p = strpbek{s,"4369"};//3最先在s中找到
printf("%s\n",p);
return 0;
}