/* split.c (Split string to blank separated fragments) 24nov97/28may98 jw */ #include #include int split( char *buf, char **ptr, int max ) { char *p = buf; int n = 0; while ( *p && n < max ) { while ( *p && isspace( *p )) p++; if ( *p == 0 ) break; if ( ptr ) ptr[n] = p; n++; while ( *p && !isspace( *p )) p++; if ( *p ) *p++ = 0; } if ( ptr ) ptr[n] = NULL; return n; } /* end of file */