• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /asuswrt-rt-n18u-9.0.0.4.380.2695/release/src-rt-6.x.4708/toolchains/hndtools-armeabi-2013.11/share/doc/arm-arm-none-eabi/html/libc/
1<html lang="en">
2<head>
3<title>strtok - 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="Strings.html#Strings" title="Strings">
9<link rel="prev" href="strstr.html#strstr" title="strstr">
10<link rel="next" href="strupr.html#strupr" title="strupr">
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="strtok"></a>
29<p>
30Next:&nbsp;<a rel="next" accesskey="n" href="strupr.html#strupr">strupr</a>,
31Previous:&nbsp;<a rel="previous" accesskey="p" href="strstr.html#strstr">strstr</a>,
32Up:&nbsp;<a rel="up" accesskey="u" href="Strings.html#Strings">Strings</a>
33<hr>
34</div>
35
36<h3 class="section">5.38 <code>strtok</code>, <code>strtok_r</code>, <code>strsep</code>&mdash;get next token from a string</h3>
37
38<p><a name="index-strtok-406"></a><a name="index-strtok_005fr-407"></a><a name="index-strsep-408"></a><strong>Synopsis</strong>
39<pre class="example">     #include &lt;string.h&gt;
40     char *strtok(char *<var>source</var>, const char *<var>delimiters</var>)
41     char *strtok_r(char *<var>source</var>, const char *<var>delimiters</var>,
42         char **<var>lasts</var>)
43     char *strsep(char **<var>source_ptr</var>, const char *<var>delimiters</var>)
44     
45</pre>
46   <p><strong>Description</strong><br>
47The <code>strtok</code> function is used to isolate sequential tokens in a
48null-terminated string, <code>*</code><var>source</var>. These tokens are delimited
49in the string by at least one of the characters in <code>*</code><var>delimiters</var>. 
50The first time that <code>strtok</code> is called, <code>*</code><var>source</var> should be
51specified; subsequent calls, wishing to obtain further tokens from
52the same string, should pass a null pointer instead.  The separator
53string, <code>*</code><var>delimiters</var>, must be supplied each time and may
54change between calls.
55
56   <p>The <code>strtok</code> function returns a pointer to the beginning of each
57subsequent token in the string, after replacing the separator
58character itself with a null character.  When no more tokens remain,
59a null pointer is returned.
60
61   <p>The <code>strtok_r</code> function has the same behavior as <code>strtok</code>, except
62a pointer to placeholder <code>*</code><var>lasts</var> must be supplied by the caller.
63
64   <p>The <code>strsep</code> function is similar in behavior to <code>strtok</code>, except
65a pointer to the string pointer must be supplied <var>source_ptr</var> and
66the function does not skip leading delimiters.  When the string starts
67with a delimiter, the delimiter is changed to the null character and
68the empty string is returned.  Like <code>strtok_r</code> and <code>strtok</code>, the
69<code>*</code><var>source_ptr</var> is updated to the next character following the
70last delimiter found or NULL if the end of string is reached with
71no more delimiters.
72
73   <p><br>
74<strong>Returns</strong><br>
75<code>strtok</code>, <code>strtok_r</code>, and <code>strsep</code> all return a pointer to the
76next token, or <code>NULL</code> if no more tokens can be found.  For
77<code>strsep</code>, a token may be the empty string.
78
79   <p><br>
80<strong>Portability</strong><br>
81<code>strtok</code> is ANSI C. 
82<code>strtok_r</code> is POSIX. 
83<code>strsep</code> is a BSD extension.
84
85   <p><code>strtok</code>, <code>strtok_r</code>, and <code>strsep</code> require no supporting OS subroutines.
86
87   <p><br>
88
89   </body></html>
90
91