const wchar_t* wmemchr (const wchar_t* ptr, wchar_t wc, size_t num);
wchar_t* wmemchr ( wchar_t* ptr, wchar_t wc, size_t num);
Locate character in block of wide characters
Searches within the first num wide characters of the block pointed by ptr for the first occurrence of wc, and returns a pointer to it (or a null pointer if not found).
Notice that, unlike wcschr, the function does not stop comparing after finding a null wide character.
This is the wide character equivalent of memchr (<cstring>).
- Pointer to the array of wchar_t elements to be searched.
- Wide character to be located.
- Number of elements of type wchar_t to compare.
size_t is an unsigned integral type.
A pointer to the first occurrence of wc in the array pointed by ptr.
If the wc is not found, the function returns a null pointer.
In C, this function is only declared as:
wchar_t * wmemchr ( const wchar_t *, wchar_t, size_t );
instead of the two overloaded versions provided in C++.
/* wmemchr example */
int main ()
wchar_t * pwc;
wchar_t wcs = L"Example wide string";
pwc = wmemchr (wcs, L'p', wcslen(wcs));
wprintf (L"'p' found at position %d.\n", pwc-wcs+1);
wprintf (L"'p' not found.\n");
- Locate character in block of memory (function
- Compare two blocks of wide characters (function
- Locate first occurrence of character in wide string (function
- Locate last occurrence of character in wide string (function