wmemchr - C wchar.h

C examples for wchar.h:wmemchr

Type

function

From


<cwchar>
<wchar.h>

Description

Locate character in block of wide characters

Prototype

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);

Parameters

Parameter Description
ptr Pointer to the array of wchar_t elements.
wc Wide character to be located.
num Number of elements of type wchar_t to compare.

Return Value

A pointer to the first occurrence of found character.

If not found, the function returns a null pointer.

Demo Code


#include <wchar.h>

int main ()/*  w  ww. j ava2 s  .  c  om*/
{
  wchar_t * pwc;

  wchar_t wcs[] = L"this is a test, test z";

  pwc = wmemchr (wcs, L'z', wcslen(wcs));

  if (pwc!=NULL)
    wprintf (L"'p' found at position %d.\n", pwc-wcs+1);
  else
    wprintf (L"'p' not found.\n");
  return 0;
}

Related Tutorials