RAD Studio
ContentsIndex
PreviousUpNext
strpbrk, _mbspbrk, wcspbrk

Header File 

string.h, mbstring.h 

Category 

C++ Prototyped Routines, Memory and String Manipulation Routines 

Prototype 

char *strpbrk(const char *s1, const char *s2); /* C only */ 

const char *strpbrk(const char *s1, const char *s2); // C++ only 

char *strpbrk(char *s1, const char *s2); // C++ only 

wchar_t * wcspbrk(const wchar_t *s1, const wchar_t *s2); 

unsigned char *_mbspbrk(const unsigned char *s1, const unsigned char *s2); 

Description 

Scans a string for the first occurrence of any character from a given set. 

strpbrk scans a string, s1, for the first occurrence of any character appearing in s2. 

Return Value 

strpbrk returns a pointer to the first occurrence of any of the characters in s2. If none of the s2 characters occur in s1, strpbrk returns null. 

Example  

#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;
}

Portability

 
POSIX 
Win32 
ANSI C 
ANSI C++ 
strpbrk 
_mbspbrk 
 
 
 
wcspbrk 
 
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!