lundi 20 avril 2015

Parse Tokens from a String using strtok()

char line[] = "COPY\tSTART\t0\tCOPY";
char *tmp;

tmp = strtok(line, "\t");
printf("%s", tmp);

This code's output is COPY. And when

char line[] = "\tSTART\t0\tCOPY";

Output is START.

But! I want to check there is nothing in front of string START. That is I think \t is first delimiter so output of strtok(line, "\t") is NULL. But real output is START.

Is there any misunderstanding? What can I do?

Aucun commentaire:

Enregistrer un commentaire