To loop over a string str I used:
for (tok = strtok(str, ";"); tok && *tok; tok = strtok(NULL, ";"))
{
//do stuff
}
I would like to understand how this loop works. It seems to me:
(1) tok = strtok(str, ";"); //initialization of tok with the first token in str
(2) tok = strtok(NULL, ";"); // go to the next token in str? how does this work?
(3) tok && *tok; //this stops the loop when tok =NULL or *tok=NULL
I would appreciate your help!