標準/拡張機能 | C/C++ | 依存項目 |
---|---|---|
ISO C |
両方 |
#include <string.h>
char *strpbrk(const char *string1, const char *string2);
string2 により示されるストリングからの任意の文字の 、string1 により示されるストリングでの最初の出現を 見つけます。
正常に実行された場合、strpbrk() は、文字を指すポインターを戻します。
string1 と string2 に共通の文字がない場合には、strpbrk() は、NULL ポインターを戻します。
⁄* CELEBS47
This example returns a pointer to the first occurrence in the
array string of either a or b.
*⁄
#include <stdio.h>
#include <string.h>
int main(void)
{
char *result, *string = "A Blue Danube";
char *chars = "ab";
result = strpbrk(string, chars);
printf("The first occurrence of any of the characters ¥"%s¥" in "
"¥"%s¥" is ¥"%s¥"¥n", chars, string, result);
}
The first occurrence of any of the characters "ab" in "A Blue Danube"
is "anube"