You need to split the string manually, since
strtok
does not return empty tokens. Using
strchr
to find each comma, you can do something like:
int count = atoi(Buff); next = strchr(Buff, ',') + 1;
while (count-- > 0) {
for (int i = 0; i < 4; ++i) {
fields[i] = next; next = strchr(next, ','); if (next == NULL) break;
*next = '\0'; next++; }
for (int i = 0; i < 4; ++i)
{
printf("%s, ", fields[i]);
}
printf("\n");
}