/**** ** 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'; } }