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