Prototype: char * strsep (char ** stringp, const char * delim );
Function: Splits a string into a group of strings. Scan backward from the position pointed to by stringp. If a character pointing to a location by delim is encountered, replace the character with null and return the address pointed to by stringp.
Strsep function, which is not supported in Windows Dev-C ++. This function is often used to write UNIX analysis strings. You can use man strsep to see how to use strsep, suppose we want to analyzeURLGet string: user_command = appleboy & test = 1 & Test2 = 2. You can use the strsep function twice to separate all strings and obtain individual names and values. Strsep (stringp, delim) the first parameter is passed into the string to be analyzed, and the second parameter is passed into the delim symbol. If stringp is a null string, the function will return NULL. In other words, strsep will find the first delim symbol in the stringp string, replace it with the \ 0 symbol, and then update stringp to the next string of the \ 0 symbol, strsep () function returns the original stringp indicator.
Example:
# Include <string. h>
# Include <stdlib. h>
Int main ()
{
Char PTR [] = {"abcdefghijklmnopqrstuvwxyz "};
Char * P, * STR = "M ";
P = PTR;
Printf ("% s \ n", strsep (& P, STR ));
Printf ("% s \ n", P );
STR = "S ";
Printf ("% s \ n", strsep (& P, STR ));
Printf ("% s \ n", P );
}
[Root @ shwhg test] # GCC test131.c
[Root @ shwhg test] #./A. Out
Abcdefghijkl
Nopqrstuvwxyz
Nopqr
Tuvwxyz