wchar_t* wcstok (wchar_t* wcs, const wchar_t* delimiters);
Split wide string into tokens
A sequence of calls to this function split wcs into tokens, which are sequences of contiguous wide characters separated by any of the wide characters that are part of delimiters.
On a first call, the function expects a C wide string as argument for wcs, whose first character is used as the starting location to scan for tokens. In subsequent calls, the function expects a null pointer and uses the position right after the end of last token as the new starting location for scanning.
This is the wide character equivalent of strtok (<cstdlib>), and operates in the same way (see strtok for more details).
- C wide string to truncate.
Notice that the contents of this string are modified and broken into smaller strings (tokens).
Alternativelly, a null pointer may be specified, in which case the function continues scanning where a previous successful call to the function ended.
- C wide string containing the delimiter wide characters.
These may vary from one call to another.
A pointer to the last token found in the wide string.
A null pointer is returned if there are no tokens left to retrieve.
/* wcstok example */
int main ()
wchar_t wcs = L"- This, a sample string.";
wchar_t * pwc;
wprintf (L"Splitting wide string \"%ls\" into tokens:\n",wcs);
pwc = wcstok (wcs,L" ,.-");
while (pwc != NULL)
pwc = wcstok (NULL,L" ,.-");
Splitting wide string "- This, a sample string." into tokens:
- Split string into tokens (function
- Get span until character in wide string (function
- Locate characters in wide string (function