#include <string.h>
char *strpbrk( const char *str1, const char *str2 );
函数返回一个指针,它指向字符串 str2 中任意字符在字符串 str1 首次出现的位置,如果不存在返回 NULL。
#include <stdio.h> #include <string.h> int main(void) { char *string1 = "abcdefghijklmnopqrstuvwxyz"; char *string2 = "onm"; char *ptr; ptr = strpbrk(string1, string2); if (ptr) { printf("strpbrk found first character: %c\n", *ptr); } else { printf("strpbrk didn't find character in set\n"); } return 0; }
输出结果:
strpbrk found first character: m