看到strtok不再支持了,改用strsep,记录一下:
#include <stdio.h>
#include <string.h>
#include <ctype.h>
int main()
{
char s[] = "today is very good! and very shine.";
char *ss = strdup(s);
char *t, *de = " !.";
while (1)
{
t = strsep(&ss, de);
if(t==NULL)
break;
if(strlen(t))
printf("word=%s, len=%d\n", t, strlen(t));
}
return 0;
}
/* 输出:
word=today, len=5
word=is, len=2
word=very, len=4
word=good, len=4
word=and, len=3
word=very, len=4
word=shine, len=5
*/