http://GameProgrammer.Com

Programming

GP Mailing List
     Thread Index
     Date Index

ATXGPSIG List
     Thread Index
     Date Index

Google
>

Home

TheGrumpyProgrammer



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: binary files in C++



On Wed, 24 May 2000, Matthew J Burke wrote:

> Help! I'm trying to modify a binary file, and I've degraded to simply
> trying to copy it using fwrite in string.h.  It run and spits out a
> slightly different binary file.  Can anybody find anything worng with this
> rough-up of my prog?

> int main{
> filepointer infile(infilename, rb), outfile(outfilename, wb)
> fread( char *buffer, size, file_length, infile)

	It appears you do not allocate any space for the buffer here.
Since files can be huge and you do not want to create a 2gig buffer, I
would create a small buffer (char buffer[8192]; or somesuch) then loop
reading in a buffer full and writing out a buffer full.

> fwrite(buffer, size, file_lenght, outfile)

--
Marc Hernandez

=================================================================
The GameProgrammer.Com mailing list is for the open discussion
of any topic related to the art, science, and business of
programming games. This list is especially tolerant of beginners.
We were all beginners once

To SUBSCRIBE or UNSUBSCRIBE please visit:
http://gameprogrammer.com/mailinglist.html