|
|
coherent
strtok() String Function strtok() Break a string into tokens #include <string.h> cchhaarr *ssttrrttookk(_s_t_r_i_n_g_1, _s_t_r_i_n_g_2); cchhaarr *_s_t_r_i_n_g_1, *_s_t_r_i_n_g_2; strtok helps to divide a string into a set of tokens. string1 points to the string to be divided, and string2 points to the character or characters that delimit the tokens. strtok divides a string into tokens by being called repeatedly. On the first call to strtok, string1 should point to the string being divided. strtok searches for a character that is _n_o_t included within string2. If it finds one, then strtok regards it as the beginning of the first token within the string. If one cannot be found, then strtok returns NULL to signal that the string could not be divided into tokens. When the beginning of the first token is found, strtok then looks for a character that _i_s included within string2. When one is found, strtok replaces it with a null character to mark the end of the first token, stores a pointer to the remainder of string1 within a static buffer, and returns the address of the beginning of the first token. On subsequent calls to strtok, set string1 to NULL. strtok then looks for subsequent tokens, using the address that it saved from the first call. With each call to strtok, string2 may point to a different delimiter or set of delimiters. ***** See Also ***** string functions, string.h COHERENT Lexicon Page 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.