Program reading data of previous 'record' into the new one to be added
Basically,
I have a program that reads a file and stores the information into a struct which then goes into a linked list. When I close the program it will write to file.
When I open the program with an existing 'record' in the txt (file to be read), add a new record, and print the contents of that new record, It displays information of the initial entry along with the newly added one appended to the end. However, if I were to add another record without closing the program, it is reading the correct information and storing the correct information. I'm puzzled as to why this problem only occurs for the first addition onto an existing list of records.
Problem only occurs when:
1.) There is an existing record to be read from in the txt file
2.) It is the first record to be added on top of the other existing records.
I also found that the data fields that got read wrong were being processed by 'fgets'.
My program is very large. If it is 6 files can I still post it here?
P.S : Works on IDE not on UNIX :(