[vox-tech] [C] randomly accessing file data in C

Mark K. Kim vox-tech@lists.lugod.org
Tue, 20 May 2003 18:45:53 -0700 (PDT)


Hello...

I'm trying to access data in a file in C.  I want to read some portion of
it, modify it, then rewrite that portion back into the file.

Reading isn't a problem -- I can use fseek or lseek or whatever and read
the data I want using fread or read.  No problem.

Writing is another matter.  When I seek to the spot and write the modified
data, it destroys the data that comes afterwards.

There's another catch: I gotta use 64-bit safe calls because the file I'm
reading/writing is quite big (> 2GB).  And since the file is so big, I
can't store the data that follows to prevent it from getting overwritten.

Anybody know how to do this?  I'm so disheartened.  Please help!!  Thanks!

-Mark

-- 
Mark K. Kim
http://www.cbreak.org/
PGP key available upon request.