strpbrk() - ストリング内の文字の検索

標準

標準/拡張機能 C/C++ 依存項目

ISO C
POSIX.1
XPG4
XPG4.2
C99
Single UNIX Specification、バージョン 3

両方  

形式

#include <string.h>

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

機能説明

string2 により示されるストリングからの任意の文字の 、string1 により示されるストリングでの最初の出現を 見つけます。

戻り値

正常に実行された場合、strpbrk() は、文字を指すポインターを戻します。

string1string2 に共通の文字がない場合には、strpbrk() は、NULL ポインターを戻します。

CELEBS47
⁄* 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"

関連情報