Strings In Depth18 / 18
Up next

strtok

#include <stdio.h>
#include <string.h>

int main(void) {
    char csv[] = "a,b,c";
    for (char *tok = strtok(csv, ","); tok != nullptr; tok = strtok(nullptr, ",")) {
        printf("%s\n", tok);
    }
    return 0;
}
What you're solving

split a mutable buffer on delimiters