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


4.10 str_tokqcnt

count the number of tokens in a string

Synopsis

#include <suplib/str.h>

int str_tokqcnt(
  char *string,
  const char *delim,
  int skip
);

Parameters

char *string

the string to parse

const char *delim

the set of characters that delimit tokens

int skip

true if consecutive delimiters are treated as a single delimiter

Description

This routine counts the number of tokens in a string as would be returned by str_tokq. It does change the input string, but restores it to its initial state upon completion. A constant string (e.g., a statically declared string) should not be passed.

Returns

Upon success it returns the number of tokens in the string. On error it returns ‘-1’.

Author

Diab Jerius