- December 26, 2006 at 8:23 pm #1956grishmaParticipant
I have been trying to write code for reading and writing a file. I am facing a problem with that. I am using fread and fwrite functions for it. I am writing data through structures in a file. I want to make a simple telephone directory to which I can enter data, search a contact and list the contacts in alphabetical order.
First of all I am writing records with fwrite function. Then I read it through fread function. What happens in this, when I open the file for reading purpose only, it repeats the last record twice in print or it shows junk values when I have given the contion to read upto EOF.
Any good technique to handle file so I can enter data any time, read it, search it and sort the records. Please reply..
- May 21, 2007 at 12:16 am #3219dham ampatuanParticipant
If you’re doing it in a loop, probably you have forgotten to update the file pointer.
use fseek (man fseek) for the same.
- You must be logged in to reply to this topic.