#include <stdio.h>
#include <string.h>
int main ()
{
char str[] ="# Timestep No_Moles No_Specs CO3 CO2 HO CHO2 O CHO3";
char * pch;
printf ("Splitting string \"%s\" into tokens:\n",str);
pch = strtok (str," #");
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " #");
}
return 0;
}
/*
given output:
Timestep
No_Moles
No_Specs
CO3 CO2 HO CHO2 O CHO3
but expected output:
Timestep
No_Moles
No_Specs
CO3
CO2
HO
CHO2
O
CHO3
*/