Random Access files

Tony R. Marasco TRM900 at psuvm.psu.edu
Sun Nov 18 19:26:03 AEST 1990


Hello.  I am trying to use random access files and have run into some
problems...

I am using _fopen_ with a "w+b" parameter to create the file (if it doesn't
exist).  If it exists, I use "r+b".  Otherwise it seems to erase the file
like PASCAL's _rewrite_.  How am I doing so far??

I am also using _fseek_ to position the file pointer (recnum*size of struct)
with SEEK_SET.  I do this before each _fread_ & _fwrite_.  The program
seems to "lose" a few bytes at the beginning of each _fread_.

What is more astounding is I can write a record that doesn't exist, but
I can't update a record that already exists.

Any ideas?  Is it my fault or Turbo C's?

Any help is greatly appreciated.
-------
| Tony Marasco                 |  "Questions are a burden for others.     |
| Penn State University        |   Answers are a prison for oneself."     |
| Schuylkill Haven, PA 17976   |     - The Prisoner                       |
| trm900 at psuvm.psu.edu       - or -   %s!psuvax1!psuvm.BITNET!trm900      |



More information about the Comp.lang.c mailing list