strtok

Example: strtokString Manipulation Functions

Returns a token from a string delimited by specified characters.

char *strtok( char *string, const char *delimiters);

string The string to scan.
delimiters The string consisting of the character or characters that delimit tokens in the first string.

strtok returns a token from a string delimited by specified characters. After the first invocation, pass NULL as the value of string to get the next token.

Return Values

On the first invocation, returns a pointer to the first token found in string. Each subsequent invocation with a NULL value of string returns the next token. Returns NULL when there are no more tokens to be found.

Insert the following at the beginning of a script that uses strtok:

extern char* strtok(char *token, const char *delimiter);

Strtok must be cast to a char pointer when assigning the return value, for example:

char *token = (char *)strtok(path, separators);