C library function strtok()




C library function strtok()

#include <cstring>
#include <iostream>

using namespace std;

int main()
{
   char str[] = "Crimson Chat,Tropical Parula,sparrow,pigeon,crow";
   char delim[] = ",";
   cout << "The tokens are:" << endl;
   char *token = strtok(str,delim);
   while (token)
   {
      cout << token << endl;
      token = strtok(NULL,delim);
   }
   return 0;
}

Output

The tokens are:
Crimson Chat
Tropical Parula
sparrow
pigeon
crow