1,头文件:
#include <string.h>
2,函数原型:
char *strpbrk(const char *str1, const char *str2)
3,函数参数:
str1 – 要被检索的 C 字符串。
str2 – 该字符串包含了要在 str1 中进行匹配的字符列表。
4,返回值:
该函数返回 str1 中第一个匹配字符串 str2 中字符的字符数,如果未找到字符则返回 NULL。
5,事例:
#include <stdio.h>
#include <string.h>
int main ()
{
const char str1[] = "abcde2fghi3jk4l";
const char str2[] = "2c";
char *ret;
ret = strpbrk(str1, str2);
if(ret)
{
printf("第一个匹配的字符是: %c\n", *ret);
}
else
{
printf("未找到字符");
}
return(0);
}