char str[] = "ABCDEFG,12:34:56:78:90:11"; //[1] char *first = strtok(str, ","); //[2] char *second = strtok(NULL, ""); //[3]
[1] ABCDEFG, 12: 34: 56: 78: 90: 11
[2] ABCDEFG \ 012: 34: 56: 78: 90: 11
Comma replaced with null character with first pointing to 'A'
[3] Subsequent calls to `strtok` have NULL` as first argument.
You can change the delimiter though.
Note: you cannot use "string literals", because `strtok` modifies the string.
N 1.1
source share