#include #include /********** * Author: G.Towell * Created: Sep 17, 2019 * Desc: * A tiny little program to illustrate the use of strok * Another function from string.h **********/ #define TOKEN_SPLIT ",:" int main () { char string[50] ="Test,string1,Test,string2:Test:string3"; char *p; printf ("String \"%s\" is split into tokens using a single char in \"%s\":\n",string, TOKEN_SPLIT); p = strtok (string,TOKEN_SPLIT); // get first token while (p!= NULL) { printf ("%s\n",p); p = strtok (NULL, TOKEN_SPLIT); // get subsequent tokens -- NOTE USE OF NULL -- cannot split two string at same time } printf ("String \"%s\" was split into tokens using a single char in \"%s\":\n",string, TOKEN_SPLIT); return 0; }