Date: Sun, 8 Mar 1998 14:26:26 +0200 (IST) From: Eli Zaretskii To: Pieter van Ginkel cc: djgpp AT delorie DOT com Subject: Re: Copy files. In-Reply-To: <6dsq61$hb2@news.euro.net> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk On 8 Mar 1998, Pieter van Ginkel wrote: > I've created this. I know it works because I've tested it, but for some > weird reason it doesn't work anymore. If I copy a file with the size of e.g. > 24 K, It copy's a random amount of data. Please help me. > > bool copyfile( char * tofile, char * fromfile ) > { > void * buffer = malloc( 1024 ); > // allocate the maximum amount of characters for buffer > size_t haveread, maximumread = 1024; > if( !*tofile || !*fromfile ) return false; // one is enty > FILE * ffile = fopen( fromfile, "r" ); > FILE * tfile = fopen( tofile, "w" ); You need to open files in binary mode. Use "wb" and "rb" in the call to `fopen'.