problem strtok in c++
<p>i have a problem in strtock in c++
i need to read the follwing line from file</p>

<p><strong>6:00,6:20,6:40,7:00,7:20,7:40,8:00,8:50,9:40,10:30,11:20,12:00</strong>
the length of the line is unknow(i dont know how many arguments i have);</p>

<p>i try to do this function:</p>

<pre><code>void RailwayLine::initilizeLoz(char line[1024])
 {

  char * pch;
  char * timeReader;
  Hour *hour;
  char * pch2=NULL;
  int time;
  int minute;
  char line2[1024];
  strcpy(line2,line);
  pch = strtok (line2,",");
 while (pch != NULL)
   {
    delete pch2;
    pch2= new char(strlen(pch)+1);
    if(pch2!=NULL)
   strcpy(pch2,pch);
    timeReader = strtok (pch2,":");
    time=atoi(timeReader);
    timeReader = strtok (NULL,":");
    minute=atoi(timeReader);
    hour=new Hour(time,minute);

           this-&gt; UpdateLoz((*hour));

             pch=strtok(NULL,",");


   }


 }
</code></pre>

<p>but  it didn't works. itj reads only the first argument (7:10)!
what can be the froblem?
how can i improve my code?
thank you</p>
