strtok.html 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <html>
  2. <head>
  3. <title>strtok</title>
  4. <body bgcolor=#ffffff>
  5. <h2 align=center>strtok</h2>
  6. <h4 align=center>OS/161 Reference Manual</h4>
  7. <h3>Name</h3>
  8. strtok - tokenize string
  9. <h3>Library</h3>
  10. Standard C Library (libc, -lc)
  11. <h3>Synopsis</h3>
  12. #include &lt;string.h&gt;<br>
  13. <br>
  14. char *<br>
  15. strtok(char *<em>string</em>, const char *<em>separators</em>);
  16. <h3>Description</h3>
  17. strtok splits up the string <em>string</em> into fields using the
  18. characters found in <em>separators</em> as delimiters. The delimiters
  19. found are discarded. Multiple delimiter characters in a row are
  20. treated as a single delimiter.
  21. <p>
  22. When first called, strtok returns the first field of <em>string</em>.
  23. To retrieve successive fields of <em>string</em>, call strtok again
  24. repeatedly, passing NULL as the first argument. When no more fields
  25. are left, NULL is returned. If the string is empty or contains only
  26. delimiters, NULL will be returned on the first call.
  27. <p>
  28. <h3>Cautions</h3>
  29. Note that the state used to remember <em>string</em> across calls is
  30. global. Thus, strtok cannot be used from more than one thread at a
  31. time in a multithreaded program, nor can it be used in a subroutine
  32. called from within a loop that itself uses strtok. If these
  33. restrictions are problematic, use <A HREF=strtok_r.html>strtok_r</A>.
  34. <p>
  35. The behavior if strtok is called again without passing a new
  36. <em>string</em> after it has returned NULL is undefined.
  37. <p>
  38. The behavior if strtok is called with the first argument NULL without
  39. having first passed a valid <em>string</em> is also undefined.
  40. <p>
  41. <h3>Return Values</h3>
  42. strtok returns successive components of the passed-in string, and
  43. NULL when no more remain.
  44. </body>
  45. </html>