Format
#include <wchar.h> wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
Language Level: ANSI 93
wmemchr locates the first occurrence of c
in the initial n wide characters of the object pointed to by s.
If n has the value 0, wmemchr finds no occurrence of c, and returns a NULL pointer.
Return Value
wmemchr returns a pointer to the located wide
character, or a NULL pointer if the wide character does not occur
in the object.
Example
This example finds the first occurrence of 'A' in
the wide-character string.
#include <stdio.h> #include <wchar.h>
main()
{
wchar_t *in = L"1234ABCD";
wchar_t *ptr;
wchar_t fnd = L'A';
printf("\nEXPECTED: ABCD");
ptr = wmemchr(in, L'A', 6);
if (ptr == NULL)
printf("\n** ERROR ** ptr is NULL, char L'A' not found\n");
else
printf("\nRECEIVED: %ls \n", ptr);
}
![]()
memchr -- Search
Buffer
strchr -- Search for
Character
strrchr -- Find
Last Occurrence of Character in String
wcschr -- Search
for Wide Character
wcsrchr --
Locate Wide Character in String
wmemcpy -- Copy
Wide-Character Strings
wmemcmp -- Compare
Wide-Character Strings
wmemmove -- Copy
Wide-Character Strings
wmemset -- Set Wide
Characters to Value
<wchar.h>