strtok
strtok関数でCSVテキストを処理してみる
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
char* str = "hoge,fuga,foobar,ほげ";
char* sepa = ",";
char* buf = (char*)malloc(strlen(str) + 1);
strcpy(buf, str);
char* s;
for(s = strtok(buf, sepa); s; s = strtok(NULL, sepa)) {
printf("%s\n",s);
}
free(buf);
}