#include <stdio.h>
#include <string.h>
int main()
{
char str[] = " I # # love you ## more than ### you can imagine!#";
char delims[] = "#";
char *result = strtok(str, delims); // 连续多个分隔符算一个
while(result != NULL)
{
printf( "%s\n", result);
result = strtok(NULL, delims);
}
return 0;
}
结果为:
I
love you
more than
you can imagine!