char* strtok(void *str, const char *delimiters)
Returns a pointer to the internal string buffer pointing to the current token, or NULL if the end of the string has been reached with no more tokens found.
Splits a string into string "tokens", split by the given delimiters. Each call to strtok returns a single token.
You can use this function to split a string into individual words by using the space character as a delimiter. You might also use it to split a line of a CSV (comma-separated-value) file by using the comma symbol as a delimiter.
%fml OnFilterStart: { char* strbuffer; char* token; strbuffer = malloc(1000); sprintf(strbuffer, "FM is awesome!"); printf("%s", strbuffer); token = strtok(strbuffer, " "); while(token != NULL) { printf("%s", token); // Use NULL here, not strbuffer // otherwise infinite loop here! token = strtok(NULL, " "); } free(strbuffer); return true; }