wcspbrk() — Locate Wide Characters in String
Format
#include <wchar.h>
wchar_t *wcspbrk(const wchar_t *string1, const wchar_t *string2);
Language Level
XPG4
Threadsafe
Yes
Wide Character Function
See Wide Characters for more information.
Description
The wcspbrk()
function
locates the first occurrence in the string pointed to by string1 of
any wide character from the string pointed to by string2.
Return Value
The wcspbrk()
function
returns a pointer to the character. If string1 and string2 have
no wide characters in common, the wcspbrk()
function
returns NULL.
Example
This example uses
wcspbrk()
to
find the first occurrence of either "a" or "b" in
the array string. #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 should be similar to: ******************
The first occurrence of any of the characters "ab" in "The Blue Danube"
is "anube"
******************************************************************/
Related Information
- strchr() — Search for Character
- strcspn() — Find Offset of First Character Match
- strpbrk() — Find Characters in String
- strspn() — Find Offset of First Non-matching Character
- wcschr() — Search for Wide Character
- wcscmp() — Compare Wide-Character Strings
- wcscspn() — Find Offset of First Wide-Character Match
- wcsncmp() — Compare Wide-Character Strings
- wcsrchr() — Locate Last Occurrence of Wide Character in String
- wcswcs() — Locate Wide-Character Substring
- <wchar.h>