wcstok - C wchar.h

C examples for wchar.h:wcstok

Type

function

From


<cwchar>
<wchar.h>

Description

Split wide string into tokens

Prototype

wchar_t* wcstok (wchar_t* wcs, const wchar_t* delimiters);

Parameters

Parameter Description
wcs C wide string to truncate.
delimiters delimiter wide characters.

Return Value

A pointer to the last token found in the wide string.

A null pointer is returned if there are no tokens left to retrieve.

Demo Code


#include <wchar.h>

int main (){/*from   w  w  w.ja  v a 2  s  .  c om*/
  wchar_t wcs[] = L"this is a test- This, a sample string.";
  wchar_t * pwc;

  wprintf (L"Splitting wide string \"%ls\" into tokens:\n",wcs);

  pwc = wcstok (wcs,L" ,.-");

  while (pwc != NULL){

    wprintf (L"%ls\n",pwc);

    pwc = wcstok (NULL,L" ,.-");
  }
  return 0;
}

Related Tutorials