function
<cwchar>
wcspbrk
const wchar_t* wcspbrk (const wchar_t* wcs1, const wchar_t* wcs2); wchar_t* wcspbrk ( wchar_t* wcs1, const wchar_t* wcs2);
Locate characters in wide string
Returns a pointer to the first occurrence in wcs1 of any of the wide characters that are part of wcs2, or a null pointer if there are no matches.
The search does not include the terminating null wide characters of either wide strings, but ends there.
This is the wide character equivalent of strpbrk (<cstring>).
Parameters
- wcs1
- C wide string to be scanned.
- wcs2
- C wide string containing the characters to match.
Return Value
A pointer to the first occurrence in wcs1 of any of the wide characters that are part of wcs2, or a null pointer if none of the characters of wcs2 is found in wcs1 before the terminating null wide character.
If none of the characters of wcs2 is present in wcs1, a null pointer is returned.
Portability
In C, this function is only declared as:
wchar_t * wcspbrk ( const wchar_t *, const wchar_t * );
instead of the two overloaded versions provided in C++.
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
/* wcspbrk example */
#include <wchar.h>
int main ()
{
wchar_t wcs[] = L"This is a sample wide string";
wchar_t key[] = L"aeiou";
wchar_t * pwc;
wprintf (L"Vowels in '%ls': ",wcs);
pwc = wcspbrk (wcs, key);
while (pwc != NULL)
{
wprintf (L"%c " , *pwc);
pwc = wcspbrk (pwc+1,key);
}
wprintf (L"\n");
return 0;
}
|
Output:
Vowels in 'This is a sample string': i i a a e i e i
|
See also
- strpbrk
- Locate characters in string (function)
- wcscspn
- Get span until character in wide string (function)
- wcschr
- Locate first occurrence of character in wide string (function)
- wcsrchr
- Locate last occurrence of character in wide string (function)
- wmemchr
- Locate character in block of wide characters (function)