wcschr - C wchar.h

C examples for wchar.h:wcschr

Type

function

From


<cwchar>
<wchar.h>

Description

Locate first occurrence of character in wide string

Prototype

const wchar_t* wcschr (const wchar_t* ws, wchar_t wc);
      wchar_t* wcschr (      wchar_t* ws, wchar_t wc);

Parameters

Parameter Description
ws C wide string.
wc Wide character to be located.

Return Value

A pointer to the first occurrence of wc in ws.

If wc is not found, the function returns a null pointer.

Demo Code


#include <wchar.h>

int main ()/*from  ww w  .  j  av a 2 s  .  com*/
{
  wchar_t wcs[] = L"This is a sample wide string";
  wchar_t * pwc;
  wprintf (L"Looking for the 's' character in \"%ls\"...\n",wcs);
  pwc=wcschr(wcs,L's');
  while (pwc!=NULL)
  {
    wprintf (L"found at %d\n",pwc-wcs+1);
    pwc=wcschr(pwc+1,L's');
  }
  return 0;
}

Related Tutorials