Random Access Files
I'm in the process of creating a program that maintains a staff details file. I've got all the code that creates a random access file, and I can add entries and sort them in the right order within the file. I have now hit a brick wall when it comes to modifying an existing record within the file. The file contains an int called recordnum to keep track of the records and to give random access, so I know how to get to the record and load it into variables but do not know how to save changes back into the same record position. Any help would be greatly appreciated.
if file is binary.... if file pointer located record originally, rewind file pointer size of 1 record to replace variables in original position on file....
fseek(fp, (-1 * sizeof(struct whatever), SEEK_CUR);
then write in the structure..
fwrite(&struct_identifier, sizeof(struct whatever), 1, fp);
should work okay.....
if you dont get it..post your code so far...