I want to write a little program to read lines from a given .csv/.txt file and print out specific details based on user input.
I'm currently working with a
FILE *input = fopen("Example.csv", "r");
and the input looks like this:
Test000, 40, 0, empty
Test001, 0, -41, empty
Now if I try to to fscanf() from input, it only sets the first char[] and ignores the other variables.
My fscanf() call looks like this:
fscanf(input, "%s , %d , %d , %s", name, &timeA, &timeB, info);
# I'm calling fscanf(...) inside of while()-condition.
# while (fscanf(...) == 4) { *apply logic here* }
So, with this code, fscanf() only ever sets name to 'Test000,', then '40', '0', 'empty' etc., but ignores timeA, timeB, and info.
They are defined as:
char name[51];
int timeA = 0;
int timeB = 0;
char info[51];
I really don't know how to circumvent this problem. Any kind of help will be appreciated!
Thank you for your time.