C中的strpbrk()

该函数strpbrk()用于查找第一个字符串的第一个字符,并将其与第二个字符串的任何字符匹配。如果未找到匹配项,则返回NULL,否则返回指向第一个字符串的字符的指针,该指针与第二个字符串的字符匹配。

这是strpbrk()C语言的语法,

char *strpbrk(const char *string1, const char *string2)

这是strpbrk()C语言的示例,

示例

#include <stdio.h>
#include <string.h>
int main () {
   const char s1[] = "Helloworld";
   const char s2[] = "Blank";
   char *result;
   result = strpbrk(s1, s2);
   printf("The matching character : %c\n", *result);
   return(0);
}

输出结果

The matching character : l