[ create a new paste ] login | about

Link: http://codepad.org/eRwUDkVh    [ raw code | output | fork ]

C++, pasted on Jun 24:
#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

*/


Output:
1
2
3
4
5
Splitting string "# Timestep     No_Moles     No_Specs     CO3	CO2	HO	CHO2	O	CHO3" into tokens:
Timestep
No_Moles
No_Specs
CO3	CO2	HO	CHO2	O	CHO3


Create a new paste based on this one


Comments: