in reply to Deleting a record from a flat text file
Perhaps if you can show us the full code that deletes the file, that would help. Sometimes monks will give you a whole program for nothing, sometimes they won't. Typically, some up front work is encouraged.
As for solving your problem there are several ways to go about it. How large is the typical file? How large is it likely to get? You can simply write the good records to a new file and rename it to the old one (which would take less memory if you have a big file), or you could read the entire file, only sticking good records into an array and then write that array back out to the file after you have truncated it at the beginning. However, these and other strategies can be dependent upon your requirements.
Cheers,
Ovid
New address of my CGI Course.
Silence is Evil (feel free to copy and distribute widely - note copyright text)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Deleting a record from a flat text file
by mikael-g (Initiate) on Jun 13, 2003 at 15:12 UTC | |
by vek (Prior) on Jun 13, 2003 at 18:52 UTC | |
by Muoyo (Novice) on Jun 13, 2003 at 19:14 UTC |