Hi guys, I have a real quick problem, or at least I hope it's really quick. The thing is, I'm studying for a computing C final, and one of the sample questions requires me to take data from a file, put it in a linked list, and then place it is a file. The actual question reads:
2) Use linked list to read data from file
The file contains 4 columns per line.
For example,
2009-11-20 125 250 350
First is date, second is breakfast, third is lunch, fourth is dinner.
If there's data already in the person's file, then read all into a linked list. Each line in the file corresponds to one node in the linked list.
Use the following node structure.
struct calorie_day {
char date[11];
int breakfast;
int lunch;
int dinner;
struct calories *next; //pointer for next day
};
If there's no data in file, the linked list should be empty.
3) Save data to file
When program exits, save all data in linked list to the person's file.
The file should contain all 4 columns per line.
It should be sorted by date.
2009-11-20 125 250 350
2009-11-21 130 150 400
2009-11-22 0 330 240
Now, even after a semester of C, I'm still a little lost when ti comes to linked lists and files because they were crammed into the last three lectures. Could you guys help me out please? Post actual code if you have to, but can you please try to help me learn rather than just giving me the answer? The final is going to tear me a new one as it is haha :P
Thank you so much.