1<html lang="en"> 2<head> 3<title>wcstok - Untitled</title> 4<meta http-equiv="Content-Type" content="text/html"> 5<meta name="description" content="Untitled"> 6<meta name="generator" content="makeinfo 4.13"> 7<link title="Top" rel="start" href="index.html#Top"> 8<link rel="up" href="Wchar-strings.html#Wchar-strings" title="Wchar strings"> 9<link rel="prev" href="wcsstr.html#wcsstr" title="wcsstr"> 10<link rel="next" href="wcswidth.html#wcswidth" title="wcswidth"> 11<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> 12<meta http-equiv="Content-Style-Type" content="text/css"> 13<style type="text/css"><!-- 14 pre.display { font-family:inherit } 15 pre.format { font-family:inherit } 16 pre.smalldisplay { font-family:inherit; font-size:smaller } 17 pre.smallformat { font-family:inherit; font-size:smaller } 18 pre.smallexample { font-size:smaller } 19 pre.smalllisp { font-size:smaller } 20 span.sc { font-variant:small-caps } 21 span.roman { font-family:serif; font-weight:normal; } 22 span.sansserif { font-family:sans-serif; font-weight:normal; } 23--></style> 24<link rel="stylesheet" type="text/css" href="../cs.css"> 25</head> 26<body> 27<div class="node"> 28<a name="wcstok"></a> 29<p> 30Next: <a rel="next" accesskey="n" href="wcswidth.html#wcswidth">wcswidth</a>, 31Previous: <a rel="previous" accesskey="p" href="wcsstr.html#wcsstr">wcsstr</a>, 32Up: <a rel="up" accesskey="u" href="Wchar-strings.html#Wchar-strings">Wchar strings</a> 33<hr> 34</div> 35 36<h3 class="section">6.26 <code>wcstok</code>—get next token from a string</h3> 37 38<p><a name="index-wcstok-419"></a><strong>Synopsis</strong> 39<pre class="example"> #include <wchar.h> 40 wchar_t *wcstok(wchar_t *<var>source</var>, const wchar_t *<var>delimiters</var>, 41 wchar_t **<var>lasts</var>) 42 43</pre> 44 <p><strong>Description</strong><br> 45The <code>wcstok</code> function is the wide-character equivalent of the 46<code>strtok_r</code> function (which in turn is the same as the <code>strtok</code> 47function with an added argument to make it thread-safe). 48 49 <p>The <code>wcstok</code> function is used to isolate (one at a time) 50sequential tokens in a null-terminated wide-character string, 51<code>*</code><var>source</var>. A token is defined as a substring not containing 52any wide-characters from <code>*</code><var>delimiters</var>. 53 54 <p>The first time that <code>wcstok</code> is called, <code>*</code><var>source</var> should 55be specified with the wide-character string to be searched, and 56<code>*</code><var>lasts</var>–but not <code>lasts</code>, which must be non-NULL–may be 57random; subsequent calls, wishing to obtain further tokens from 58the same string, should pass a null pointer for <code>*</code><var>source</var> 59instead but must supply <code>*</code><var>lasts</var> unchanged from the last 60call. The separator wide-character string, <code>*</code><var>delimiters</var>, 61must be supplied each time and may change between calls. 62A pointer to placeholder <code>*</code><var>lasts</var> must be supplied by 63the caller, and is set each time as needed to save the state 64by <code>wcstok</code>. Every call to <code>wcstok</code> with <code>*</code><var>source</var> 65== <code>NULL</code> must pass the value of <code>*</code><var>lasts</var> as last set 66by <code>wcstok</code>. 67 68 <p>The <code>wcstok</code> function returns a pointer to the beginning of each 69subsequent token in the string, after replacing the separator 70wide-character itself with a null wide-character. When no more tokens 71remain, a null pointer is returned. 72 73 <p><br> 74<strong>Returns</strong><br> 75<code>wcstok</code> returns a pointer to the first wide character of a token, or 76<code>NULL</code> if there is no token. 77 78 <p><br> 79<strong>Portability</strong><br> 80<code>wcstok</code> is C99 and POSIX.1-2001. 81 82 <p><code>wcstok</code> requires no supporting OS subroutines. 83 84 <p><br> 85 86 </body></html> 87 88