---
name: "string_to_tokens"
section: "3"
platform: "linux"
package: "ltp-dev"
version: "20091231+dfsg-1"
release: "Debian 6.0 (Squeeze)"
platforms: ["linux"]
url: "https://new.carta.tech/string_to_tokens"
---

# string\_to\_tokens(3)

Break a string into its tokens

## NAME

string\_to\_tokens - Break a string into its tokens

## SYNOPSIS

```
int string_to_tokens(arg_string, arg_array, array_size, separator)
char *arg_string;
char *arg_array[];
int array_size;
char *separator;
```

## DESCRIPTION

This function parses the string *arg\_string*, placing pointers to the *separator* separated tokens into the elements of *arg\_array*. The array is terminated with a null pointer. *arg\_array* must contains at least *array\_size* elements. Only the first *array\_size* minus one tokens will be placed into *arg\_array*.  If there are more than *array\_size*-1 tokens, the rest are ignored by this routine.

## SEE ALSO

[strtok(3)](/strtok/3.md).

## DIAGNOSTICS

This function returns the number of *separator* separated tokens that were found in *arg\_string*. If *arg\_array* or *separator* is NULL or *array\_size* is less than 2, -1 is returned.

## BUGS

This function uses **strtok()** to parse *arg\_string*, and thus physically alters *arg\_string* by placing null characters where the separators originally were.
