Reading Data From File to Linked List
The data from the text file looks like:
40T Trapp, Dave; 3.9
pin# Last_Name, First_Name; gpa
I am trying to read them into a linked list composed of the structure:
Code:
typedef struct
{
char pin[4];
char *name;
double gpa;
} STU;
So far the function I used to read the data from the file worked successfully for my test file which was only contained integers and placed them into a sorted linked list.
My only concern now is modifying it to accommodate the data I need.
I was told that I should use fgets and sscanf but I am not too certain of how to go about doing this, especially since we only covered sscanf very briefly so I am still not very sure of what it does and I can't find very clear examples online.
Here's the original function:
Code:
int getData (FILE* fpData, STU* pData)
{
int ioResult;
ioResult = fscanf (fpData, "%d ", pData->test);
if (ioResult == 1)
return 1;
else
return 0;
} // getData
I am calling it inside of a larger function which builds the sorted list.
Any and all feedback is appreciated