The strstr () command is to find the address of the first occurrence of the specified string in the original string, which enables the segmentation of the character and the ability to determine if the inclusion is possible:
The following example is an implementation string that splits the output of a split string:
1 #include <stdio.h>
2 #include <string.h>
3
4 int main ()
5 {
6 char *str= "aaa| |a| | bbb| | c| | ee| | ";
7 char *sp= "| |";
8
9 Char *pos = STRSTR (STR,SP);//Find the address of the delimiter from the original string
Ten char *lastpos = str;//Last address, first of course the original string's first address
11 while (pos! = NULL)
Ten {
(Pos-lastpos) > 0)//Two split strings exist between characters
+
15 int i = 0;
Do
+ {
printf ("%c", * (Lastpos + i));//output characters from the previous address to the current address
19 i++;
20}
while ((Lastpos + i) < POS);
printf ("\ n");//Add line wrapping at the end
+
Lastpos = pos + strlen (SP);//new String header is the address location that was last found + Split-length
pos = strstr (LASTPOS,SP);//start looking for the next delimiter position from the new string address
"
" return 0;
*/*
29 Output:
+ AAA
+ a
+ BBB
+ C
ee
*/
3 6}
The use of the C-language string command Strstr () enables the original string to be split into a split-string output "go"