wcspbrk() — Locate first wide characters in string

Standards

Standards / Extensions C or C++ Dependencies

ISO C Amendment
XPG4
XPG4.2
C99
Single UNIX Specification, Version 3

both  

Format

#include <wchar.h>

wchar_t *wcspbrk(const wchar_t *string1, const wchar_t *string2);

General description

Locates the first occurrence in the string pointed to by string1 of any character from the string pointed to by string2.

The behavior of this wide-character function is affected by the LC_CTYPE category of the current locale. If you change the category, undefined results can occur.

Returned value

If successful, wcspbrk() returns a pointer to the character.

If no wchar_t from string2 occurs in string1, wcspbrk() returns NULL.

Example

CELEBW16
⁄* CELEBW16                                      

   This example returns a pointer to the first occurrence in the                
   array string of either a or b, using &wcspbrk..                              
                                                                                
 *⁄                                                                             
#include <stdio.h>                                                              
#include <wchar.h>                                                              
                                                                                
int main(void)                                                                  
{                                                                               
  wchar_t * result;                                                             
  wchar_t * string = L"The Blue Danube";                                        
  wchar_t *chars = L"ab";                                                       
                                                                                
  result = wcspbrk( string, chars);                                             
   printf("The first occurrence of any of the characters \"%ls\" in "           
          "\"%ls\" is \"%ls\"\n", chars, string, result);                       
}                                                                               
Output:
The first occurrence of any of the characters "ab" in "The Blue Danube" is "anube"

Related information