原型:char *strtok(char s[], const char *delim); (在string.h函数库里
分解字符串为一组字符串。s为要分解的字符,delim为分隔符字符(如果传入字符串,则传入的字符串中每个字符均为分割符)。首次调用时,s指向要分解的字符串,之后再次调用要把s设成NULL。
例如:
<pre name="code" class="cpp">#include<stdio.h>
#include<string.h>
int main(void)
{
char str[10] = "asdc##dsf";
char *p;
p = strtok(str, "##");
if(p) printf("%-7s", p);
p = strtok(NULL, "##");
if(p) printf("%s\n", p);
return 0;
}
结果为: