ustrtok_r

Reentrant function to retrieve tokens from a string.

Description

char *ustrtok_r(char *s, const char *set, char **last);
Reentrant version of ustrtok. The `last' parameter is used to keep track of where the parsing is up to and must be a pointer to a char * variable allocated by the user that remains the same while parsing the same string. Example:
      char *word, *last;
      char string[]="some-words with dashes";
      char *temp = ustrdup(string);
      word = ustrtok_r(string, " -", &last);
      while (word) {
	 allegro_message("Found `%s'\n", word);
	 word = ustrtok_r(NULL, " -", &last);
      }
      free(temp);
Returns a pointer to the token, or NULL if no more are found. You can free the memory pointed to by `last' once NULL is returned.
See Also:

Related Projects

The following projects include source code containing this keyword: