#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 test_strsep.c
[root@shwhg test]# ./a.out
abcdefghijkl
nopqrstuvwxyz
nopqr
#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 test_strsep.c
[root@shwhg test]# ./a.out
abcdefghijkl
nopqrstuvwxyz
nopqr
tuvwxyz
http://antyoung.blog.51cto.com/2471749/655593