Re: Frustration - Input Output Question



On 2006-02-24, Freddy <zfreddyzzz@xxxxxxxxx> wrote:
Hi,

I have a C/C++ program..

I'm using a certain file to dump lots of computed numbers in it because
I might need to check them later on...so the only way I was able to do
that is by "appending" all the data to that file...because if I use the
"write" ("w") function..everytime the iteration takes place it will
delete the previous data.

if I run the program X number of times...that file is just being
appended..and its size is becoming huge...and I have to always remember
to delete the old file before I run my program again in case I needed
to check those number..

so my question is: is there a way I can delete the old file only when I
start executing the program again....I mean I want to dump all the data
of one run in that file..but when I run the program again I want to
delete the old file...and let it recreate it again...


If I have read correctly it is as simple as:

You want to recreate/reset the file every time you start your
program:

use fopen at the start with the appropriate flag at the start of the
program. "w". It truncates the file or creates it if it wasnt already
there. You can then keep using this for appending later using the same
FILE object.

The key here is, if I understand you, is that you must keep using this
SAME "FILE *" for later file writes : do not close it until you are
finished. It sounds to me that you are reopening and closing the file
in your computational loops in append mode ("a") without recreating it
at the start of your program.

Good luck!
.



Relevant Pages

  • Frustration - Input Output Question
    ... I have a C/C++ program.. ... I'm using a certain file to dump lots of computed numbers in it because ... delete the old file...and let it recreate it again... ... original data and then when the program hits its usual point the file ...
    (comp.lang.c)
  • Re: When not connected remotely, computer searches for remote computer?!?!
    ... The final fix was to dump the user's local profile and recreate it.... ...
    (microsoft.public.windowsxp.perform_maintain)
  • RE: Copy DSS Dump File to DASD
    ... and then recreate the dump on disk with the same ... command does not seem to be a good option, I'd just try to recreate the ... DISK, ... We've had a number of small DSS DUMP files written to tape that I want ...
    (bit.listserv.ibm-main)
  • Re: Database dump size
    ... Used the maintenance plan wizard to set it up. ... It's a dump to disk. ... appending the dump. ...
    (microsoft.public.sqlserver.server)
  • Backup via hyperlinked button
    ... a dump of my database to a file with inserts etc, ... recreate should I need to? ... Right now I have to login, and do a few things to make this happen. ...
    (alt.php)