|
|
1.1 root 1:
2:
3: strtok() String Function strtok()
4:
5:
6:
7:
8: Break a string into tokens
9:
10: #include <string.h>
11: cchhaarr *ssttrrttookk(_s_t_r_i_n_g_1, _s_t_r_i_n_g_2);
12: cchhaarr *_s_t_r_i_n_g_1, *_s_t_r_i_n_g_2;
13:
14: strtok helps to divide a string into a set of tokens. string1
15: points to the string to be divided, and string2 points to the
16: character or characters that delimit the tokens.
17:
18: strtok divides a string into tokens by being called repeatedly.
19:
20: On the first call to strtok, string1 should point to the string
21: being divided. strtok searches for a character that is _n_o_t
22: included within string2. If it finds one, then strtok regards it
23: as the beginning of the first token within the string. If one
24: cannot be found, then strtok returns NULL to signal that the
25: string could not be divided into tokens. When the beginning of
26: the first token is found, strtok then looks for a character that
27: _i_s included within string2. When one is found, strtok replaces
28: it with a null character to mark the end of the first token,
29: stores a pointer to the remainder of string1 within a static
30: buffer, and returns the address of the beginning of the first
31: token.
32:
33: On subsequent calls to strtok, set string1 to NULL. strtok then
34: looks for subsequent tokens, using the address that it saved from
35: the first call. With each call to strtok, string2 may point to a
36: different delimiter or set of delimiters.
37:
38: ***** See Also *****
39:
40: string functions, string.h
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64: COHERENT Lexicon Page 1
65:
66:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.