Article View: borland.public.cppbuilder.nativeapi
Article #11216Re: how to delete entry from binary file
From: Asger J�rgensen
Date: Fri, 20 Feb 2004 03:17
Date: Fri, 20 Feb 2004 03:17
22 lines
1769 bytes
1769 bytes
Hi ScOe In article <40355519@newsgroups.borland.com>, ScOe says : > I'm using fwrite to write structure to file, I also use fread to retreive > it. But i dont know how to delete it. > For example i write few objects into file, and than i want to delete 5th > object from file. > I set pointer to that position as: > fseek(stream, sizeof (myStruct) * objectnum, 0); > after that i want to delete sizeof (myStruct) number of bytes from file. How In adition to what Remy said, i will just say that unless You are planning on having a huge amount of data in the file (over 1 MB) You are better of having a list or a vector containing all Your structs and then at apropriate time save the lot to the file overwriting whats already there. The file aproach is very very slow compared to having every thing in memory. Best regards Asger
Technical Details
Message-ID:
<MPG.1a9f9aab2ec33e6d989727@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!feed2.newsreader.com!newsreader.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<40355519@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,8399063c6dc327e5 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-19 19:30:36 PST From: Asger J�rgensen <Asger.Pnotthis@AJ-World.dk> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: how to delete entry from binary file Date: Fri, 20 Feb 2004 04:17:18 +0100 Message-ID: <MPG.1a9f9aab2ec33e6d989727@newsgroups.borland.com> References: <40355519@newsgroups.borland.com> Organization: AJ-World X-Newsreader: MicroPlanet Gravity v2.50 NNTP-Posting-Host: 80.164.88.221 X-Trace: newsgroups.borland.com 1077246996 80.164.88.221 (19 Feb 2004 19:16:36 -0800) Lines: 22 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!feed2.newsreader.com!newsreader.com!newshosting.com!nx01.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail