返回值:返回下一个分割后的字符串指针,若是已无从分割则返回NULL。 函数
#include <string.h> main(){ char s[] = "ab-cd : ef;gh :i-jkl;mnop;qrs-tu: vwx-y;z"; char *delim = "-: "; char *p; printf("%s ", strtok(s, delim)); while((p = strtok(NULL, delim))) printf("%s ", p); printf("\n"); }
ab cd ef;gh i jkl;mnop;qrs tu vwx y;z //-与:字符已经被\0 字符取代 spa
c语言函数手册 .net