File Handling



Hi all,

I hoping somebody will be able to help me this a tedious problem I'm
having which I just can't seem to get right.

I open this file as a file I want to read and write to, it holds an
integer value.
I want to do this repeatedly, in this order:
1. fopen the file
2. read the value from the file
3. write a value to the file (overwriting the previous interger so
before there was 1 value, and after there is 1 value, the new one)
4. fclose the file.

fCurrProduction = fopen(CurrentProduction,"w+");
I have tried this way, but everytime i come to read from it in step 2
nothing exists in the file even though there was before the program
was run, it seems to wipe the value.

fCurrProduction = fopen(CurrentProduction,"r+");
This way seems to append the file when I want to overwrite

I manually set the files contents to zero, as i want to read an
initial value of zero from it at the beginning.

Can anybody help??
Thanks alot
Daniel

.



Relevant Pages

  • Re: recv not completely overwriting last string
    ... >> Is it me or is the recvfunction not erasing but only overwriting ... > zero-terminated strings, in which case it seems pretty clear that your ... > the length too, and append the zero ...
    (comp.lang.c)
  • Re: TM Tape is Always Finite
    ... for finite definitions of "always". ... the behavior "after" infinite steps, ... The _next_ zero merely enables the overwriting of the ...
    (comp.theory)
  • Re: "Clean a Mini
    ... Pop the OS disk in, boot off it, go to Tools/Disk Utility and erase ... For a bit of extra security go into options and choose 'zero all data', ... put a day aside if you're going to use one of the overwriting options... ...
    (uk.comp.sys.mac)
  • Re: Deleted file retrieval
    ... types of recovery, Software & Hardware. ... that does what's called a "Zero Fill" - Writes Zeros to all areas ... completely overwritten numerous times, ... unretrievable by overwriting it's data with another file of equal or ...
    (microsoft.public.windowsxp.general)
  • Re: Deleted file retrieval
    ... types of recovery, Software & Hardware. ... that does what's called a "Zero Fill" - Writes Zeros to all areas ... completely overwritten numerous times, ... unretrievable by overwriting it's data with another file of equal or ...
    (microsoft.public.windowsxp.general)