Re: Frustration - Input Output Question
- From: "Richard G. Riley" <rgrdev@xxxxxxxxx>
- Date: 24 Feb 2006 16:41:38 GMT
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!
.
- References:
- Frustration - Input Output Question
- From: Freddy
- Frustration - Input Output Question
- Prev by Date: Way for computing random primes in standard C.
- Next by Date: Re: How to install lapack in fedora core 4?
- Previous by thread: Frustration - Input Output Question
- Next by thread: Re: Frustration - Input Output Question
- Index(es):
Relevant Pages
|