Using strtok() in a loop in C?
- by Alex Xander
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
 }