Format
#include <wchar.h>
wchar_t *wmemchr(const wchar_t *s, wchar_t c, size_t n);
Language Level: ANSI
Threadsafe: Yes.
Wide Character Function: See Wide Characters for more information.
Description
The wmemchr() function 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, the wmemchr() function finds no occurrence of c, and returns a NULL pointer.
Return Value
The wmemchr() function returns a pointer to the located wide character, or a NULL pointer if the wide character does not occur in the object.
Example that uses wmemchr()
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);
}
Related Information