Re: Overwriting a portion of a binary file
- From: "Default User" <defaultuserbr@xxxxxxxxx>
- Date: 26 Jan 2006 23:48:07 GMT
mohammad.nabil.h@xxxxxxxxx wrote:
> I've been working on a database management system, and i have met a
> problem when i update a row, i found that fwrite() and _write, writes
> to the end of the file, even if i hade rewind() the file before it. As
> far as i can guess, they `append', i am looking for something that
> overwrites. of course i can't load the 'whole' file in memory, change
> it, then resave it again. the whole memory might not be enough.
>
> my code always insists on storing 'bar' after 'foo'. i want to save
> 'bar' instead of 'foo'
>
> here is a peek of my code :
We don't want a peek, we want a long, lingering look at the whole thing.
> void add_record(record* rec)
> {
> // m_db is a FILE*
Where is the code that created this FILE*?
> //fseek(m_db,0,SEEK_END);
> //fwrite(rec,record_size(),1,m_db);
> _write(fileno(m_db),rec,record_size()); // both function result in
> the same output
There is no _write() function in the C language.
> any help greatly appreciated
Post a complete, minimal, compilable program that demonstrates the
problem.
Brian
--
Please quote enough of the previous message for context. To do so from
Google, click "show options" and use the Reply shown in the expanded
header.
.
- References:
- Overwriting a portion of a binary file
- From: mohammad . nabil . h
- Overwriting a portion of a binary file
- Prev by Date: Re: Question about the clc string lib
- Next by Date: Re: How to find the dependencies among C files
- Previous by thread: Overwriting a portion of a binary file
- Next by thread: Re: Overwriting a portion of a binary file
- Index(es):
Relevant Pages
|