Using strtok() in a loop in C?
        Posted  
        
            by Alex Xander
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Alex Xander
        
        
        
        Published on 2009-10-02T13:55:11Z
        Indexed on 
            2010/05/20
            15:20 UTC
        
        
        Read the original article
        Hit count: 306
        
c
|string-manipulation
I am trying to use strtok() in nested loop. But this is not giving me desired results. Possibly because they are using same memory location. My code is of the form:-
char *token1 = strtok(Str1, "%");
while(token1 != NULL )
{
  char *token2 = strtok(Str2, "%");
  while(token2 != NULL )
   {
      //DO SMTHING
      token2 = strtok(NULL, "%");
    }
     token1 = strtok(NULL, "%");
     // Do something more
 }
© Stack Overflow or respective owner