📄 strtok.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head> <meta name="generator" content= "HTML Tidy for Linux/x86 (vers 1 September 2005), see www.w3.org"> <title>strtok</title> <link href="../cppreference.css" rel="stylesheet" type="text/css"></head><body><table> <tr> <td> <div class="body-content"> <div class="header-box"> <a href="../index.html">cppreference.com</a> > <a href= "index.html">Standard C String and Character</a> > <a href= "strtok.html">strtok</a> </div> <div class="name-format"> strtok </div> <div class="syntax-name-format"> Syntax: </div> <pre class="syntax-box"> #include <string.h> char *strtok( char *str1, const char *str2 );</pre> <p>The strtok() function returns a pointer to the next "token" in <em>str1</em>, where <em>str2</em> contains the delimiters that determine the token. strtok() returns <strong>NULL</strong> if no token is found. In order to convert a string to tokens, the first call to strtok() should have <em>str1</em> point to the string to be tokenized. All calls after this should have <em>str1</em> be <strong>NULL</strong>.</p> <p>For example:</p> <pre class="example-code"> char str[] = "now # is the time for all # good men to come to the # aid of their country"; char delims[] = "#"; char *result = <strong>NULL</strong>; result = strtok( str, delims ); while( result != <strong>NULL</strong> ) { printf( "result is \"%s\"\n", result ); result = strtok( <strong>NULL</strong>, delims ); } </pre> <p>The above code will display the following output:</p> <pre class="example-code"> result is "now " result is " is the time for all " result is " good men to come to the " result is " aid of their country" </pre> <div class="related-name-format"> Related topics: </div> <div class="related-content"> <a href="strchr.html">strchr</a><br> <a href="strcspn.html">strcspn</a><br> <a href="strpbrk.html">strpbrk</a><br> <a href="strrchr.html">strrchr</a><br> <a href="strspn.html">strspn</a><br> <a href="strstr.html">strstr</a> </div> </div> </td> </tr> </table></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -