Problem with this file

Pages: 12
And I am waiting for your help.
No one wanna help?
If I understand correctly the problem is that when you delete an entry you actually leave a blank entry in its place... You see, this is not directly a c++ problem...

If you don't need the data stored to be sorted in some way a solution to this could be storing somewhere in your file the number of entries and the places of blank entries so that when you add a new student you make sure it fills a pre-existing empty slot rather than just be appended in the end of the file. So, basically when you delete entries there appear blanks but when you add entries these blanks are filled. However if the number of the blank entries is too big, you may also want to reconstruct the file at some extent...

If you want the data stored to be sorted than I guess (but maybe I'm wrong) you have to rewrite the whole file each time you make a change... However I would keep the data in file unsorted and if I wanted to sort depending on id for example I'd load the entry numbers and ids in ram and sort it there. You see this is a good approach because you can just sort on the fly depending on any criteria you feel like.
Last edited on
Topic archived. No new replies allowed.
Pages: 12