I tried this and I found something intresting:
Here is my code:
---------------------
Code:
int main(int argc, char *argv[])
{
FILE *inputFp;
FILE *outputFp;
int shift = 0;
STRING Pattern;
STRING Text;
char buffer[BUFFER_LEN];
char lenArray[100];
char field[200];
char *ptr = NULL;
char *patternTmp, *textTmp, *expect;
int len;
int n;
inputFp = fopen(INPUT, "r");
if (inputFp == NULL) {
printf("Can't open input file: TestCases.in");
exit(0);
}
outputFp = fopen(OUTPUT, "w");
if (outputFp == NULL) {
printf("Can't open output file: TestResults.out");
exit(0);
}
/* Read the input file */
while (fgets(buffer, BUFFER_LEN, inputFp)) {
ptr = strtok(buffer, "\n");
while (sscanf(ptr, "%199[^;]%*c%n", field, &n) == 1) {
ptr += n;
printf("field = %s\n", field);
}
}
fclose(inputFp);
fclose(outputFp);
My input file
----------------
dog;This is a dog;11
cat;no cat here;4
EMPTY;blabla;-1
EMPTY;EMPTY;1
dog;This dog;11
My output
-------------
field = dog
field = This is a dog
field = 11
field = cat
field = no cat here
field = 4
field = EMPTY
field = blabla
field = -1
field = /* I am not sure this */
field = EMPTY
field = EMPTY
field = 1
field = dog
field = This dog
field = 11
}