I am new to C and I need to read in a .txt file where there are 3 fields in each line separated by a comma, and I need to save it into an array. I am wondering how to do this? Here is an example file:
0, "test", 100
1, "hi", 2
2, "goodbye", 0
So I am wondering how to read the file line by line and to store each element into an array. I have started by defining a struct:
typedef struct data {
int col1;
char *col2;
int col3;
} data_t;
Could anyone help me out to get started with the file opening?