Re: fwrite() misses writing a byte
- From: Army1987 <army1987@xxxxxxxxx>
- Date: Sun, 07 Oct 2007 12:35:13 +0200
On Wed, 03 Oct 2007 12:33:07 +0200, Joachim Schmitz wrote:
<hemant.gaur@xxxxxxxxx> schrieb im Newsbeitrag[...]
news:1191406222.184155.83240@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I have an application which writes huge number of bytes into the
binary files which is just some marshalled data.
int len = Data.size(); //arrary size
for (int i = 0; i < len; ++i)
fwrite(&Data[i], 1, 1, f);
Your code looks like C++ to me, so you may want to ask in comp.lang.c++Replacing Data.size() with a constant and using a suitable
declaration for Data the code is valid C99. Also, the only draft
of the C++ standard I've seen (and probably IMO also the real one)
defines fwrite and the rest of the library as by textual inclusion
of clause 7 of the C standard. So, unless there is something wrong
with Data::size(), that's not actually a C++ problem.
(Anyway, we don't see enough code to tell what's wrong, so the
only topical answer here is "probably there's a IO error, check
the result of fwrite", and given the OP's description of the
problem it is not very unlikely.)
--
Army1987 (Replace "NOSPAM" with "email")
A hamburger is better than nothing.
Nothing is better than eternal happiness.
Therefore, a hamburger is better than eternal happiness.
.
- References:
- fwrite() misses writing a byte
- From: hemant . gaur
- Re: fwrite() misses writing a byte
- From: Joachim Schmitz
- fwrite() misses writing a byte
- Prev by Date: Code review of an matrix rotation function
- Next by Date: Re: C needs a BOOST
- Previous by thread: Re: fwrite() misses writing a byte
- Next by thread: Re: fwrite() misses writing a byte
- Index(es):