Char *strtok (char *s, const char *delim);
Decomposes a string into a set of strings. S is the string to be decomposed, Delim is the delimiter string.
A segmented string starting from the beginning of S. Null is returned when there is no split string.
Note: When the Strtok function is called for the first time, the function ignores the spacing delimiter and returns the first character found in the Strtoken string
Number, and the symbol ends with a null character. By invoking a series of strtok functions, more symbols will be divided from the Strtoken string
Away. Each time the Strtok function is called, the Strtoken string is modified by inserting a null character after the symbol that is found. To
Reads the next symbol in the Strtoken, and when the Strtok function is called, the Strtoken parameter is null, which throws the Strtok function in the modified
The Strtoken string to find the next symbol.
#include <stdio.h>#include<string.h>intMain () {CharStr[] ="MV A.C B.C"; Char*p; P= Strtok (str," "); while(p) {printf ("%s\n", p); P= Strtok (NULL," "); } return 0;}
In the later version of Linux2.6.29, Strtok was replaced by STRSEP.
Specific examples are as follows:
#include <stdio.h>#include<string.h>intMain () {CharStr[] ="MV A.C B.C"; Char*p; Char*Buff; Buff=str; P= Strsep (&buff," "); while(p!=null) {printf ("%s\n", p); P= Strsep (&buff," "); } return 0;}
String splitting functions in C language