I parse 3 values ββin parallel, which are separated by a specific separator.
token1 = strtok_s(str1, separator, &nextToken1); token2 = strtok_s(str2, separator, &nextToken2); token3 = strtok_s(str3, separator, &nextToken3); while ((token1 != NULL) && (token2 != NULL) && (token3 != NULL)) {
Suppose '-' is my delimiter. The behavior is that a string without consecutive delimiters:
1-2-3-45
will effectively result in each of these parts:
1 2 3 45
However, a line with two consecutive delimiters:
1-2
will not output a string of length 0, which is skipped so that the result:
1 2 3 45
but not
1 2 3 45
Which workaround or strategy is best suited to get all the actual parts, including zero-length? I would like to avoid reimplementing strtok_s if possible.
source share