This commit is contained in:
fofolee
2019-04-21 11:50:48 +08:00
parent 359d29ee0b
commit 38dcd51d8a
6901 changed files with 258583 additions and 2326828 deletions

View File

@@ -1,45 +1,45 @@
<h1>字符串函数 - strtok</h1>
<p>原型extern char *strtok(char *s, char *delim);</p>
<p>用法:#include &lt;string.h></p>
<p>功能分解字符串为一组标记串。s为要分解的字符串delim为分隔符字符串。</p>
<p>说明首次调用时s必须指向要分解的字符串随后调用要把s设成NULL。</p>
<pre><code class="language-c">
strtok在s中查找包含在delim中的字符并用NULL('\0')来替换,直到找遍整个字符串。
返回指向下一个标记串。当没有标记串时则返回空字符NULL。
</code></pre>
举例:<pre><code class="language-c">
// strtok.c
#include &lt;syslib.h>
#include &lt;string.h>
#include &lt;stdio.h>
main()
{
char *s="Golden Global View";
char *d=" ";
char *p;
clrscr();
p=strtok(s,d);
while(p)
{
printf("%s\n",s);
strtok(NULL,d);
}
getchar();
return 0;
}
</code></pre>相关函数:<a href="strcspn.html">strcspn</a>,<a href="strpbrk.html">strpbrk</a>
<h1>字符串函数 - strtok</h1>
<p>原型extern char *strtok(char *s, char *delim);</p>
<p>用法:#include &lt;string.h></p>
<p>功能分解字符串为一组标记串。s为要分解的字符串delim为分隔符字符串。</p>
<p>说明首次调用时s必须指向要分解的字符串随后调用要把s设成NULL。</p>
<pre><code class="language-c">
strtok在s中查找包含在delim中的字符并用NULL('\0')来替换,直到找遍整个字符串。
返回指向下一个标记串。当没有标记串时则返回空字符NULL。
</code></pre>
举例:<pre><code class="language-c">
// strtok.c
#include &lt;syslib.h>
#include &lt;string.h>
#include &lt;stdio.h>
main()
{
char *s="Golden Global View";
char *d=" ";
char *p;
clrscr();
p=strtok(s,d);
while(p)
{
printf("%s\n",s);
strtok(NULL,d);
}
getchar();
return 0;
}
</code></pre>相关函数:<a href="strcspn.html">strcspn</a>,<a href="strpbrk.html">strpbrk</a>