I came across a code which extracted a token(c string) from a given string,but I am confused by the 5th line:tok && *tok
. I just cannot figure out this operation's result. Does anybody happen to know?
const char* getfield(char* line, int num)
{
const char* tok;
for (tok = strtok(line, ";");
tok && *tok;
tok = strtok(NULL, ";\n"))
{
if (!--num)
return tok;
}
return NULL;
}
Thank you!