要遍历我使用的字符串 str:
for (tok = strtok(str, ";"); tok && *tok; tok = strtok(NULL, ";"))
{
//do stuff
}
我想了解这个循环是如何工作的。在我看来:
(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
我会很感激你的帮助!