It seems that the input file is actually CSV format. I would suggest to refer to
Read .csv file in C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
const char* getfield(char* line, int num)
{
const char* tok;
for (tok = strtok(line, ",");
tok && *tok;
tok = strtok(NULL, ";
"))
{
if (!--num)
return tok;
}
return NULL;
}
int main()
{
FILE* stream = fopen("input", "r");
char line[1024];
while (fgets(line, 1024, stream))
{
char* tmp = strdup(line);
printf("Field 3 would be %s
", getfield(tmp, 3));
// NOTE strtok clobbers tmp
free(tmp);
}
}
You could also looks for CSV parser
libraries such as:
https://github.com/semitrivial/csv_parser
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…