标签:
/**** ** line 被分割的字符串 ** delimiter 分隔符(此处为单个字符) ** items 存储分割结果的数组 ****/ int Split( char* line, char delimiter, char * items[] ) { int cnt = 0; for (;;) { items[cnt++] = line; line = strchr( line, delimiter ); if ( line == NULL ) return cnt; *line++ = ‘\0‘; } }
/**** ** line 被分割的字符串 ** delimiter 分隔符(此处为字符串) ** items 存储分割结果的数组 ****/ int SplitEx( char* line, char *delimiter, char * items[] ) { int cnt = 0; for (;;) { items[cnt++] = line; line = strstr( line, delimiter ); if ( line == NULL ) return cnt; *line++ = ‘\0‘; *line++ = ‘\0‘; } }
字符串分割函数(1个或者2个关键字作为分隔符;稍作修改可改为多个)
标签:
原文地址:http://www.cnblogs.com/jkszbf/p/5663971.html