Next: , Previous: str_dtokcnt, Up: Strings   [Contents]


4.21 str_dtoksplit

split a string into tokens.

Synopsis

#include <suplib/str.h>

size_t str_dtoksplit(
  char *str,
  char *tok[],
  const char *delim,
  int ntok
);

Parameters

char *str

the string to split up

char *tok[]

the array to stick

const char *delim

the delimiters to split on

int ntok

the maximum number of tokens to read

Description

This routine splits a string into a series of tokens. Unlike the system library function strtok, each instance of a delimiter implies a token. In strtok, sequential delimiters are collapsed into one. This function allows one to have empty tokens. It fills a caller provided array with pointers to the tokens. The caller may specify a maximum number of tokens to read. Note that an empty string corresponds to a single, empty, token.

The passed string is modified (end of string characters are inserted where necessary).

Returns

It returns the number of tokens read.

Author

Diab Jerius