Function Strtok
char * strtok ( char * str, const char * delimiters );
What it does : Split string into tokens
A sequence of calls to this function split str into tokens,
which are sequences of contiguous characters separated by any of
the characters that are part of delimiters
Example
/* strtok example */ int main () { char str[] ="This-is Go,Hired Site."; char * pch; printf ("Splitting string "%s" into tokens:n",str); printf ("--------"); pch = strtok (str," ,.-"); // ',' '.' and '-' will be removed while (pch != NULL) { printf ("%sn",pch); pch = strtok (NULL, " ,.-"); } return 0; }
Output:
Splitting string “This-is Go,Hired Site.” into tokens:
——–
This is Go Hired Site
——–
This is Go Hired Site