From: "Pieter van Ginkel" Newsgroups: comp.os.msdos.djgpp Subject: Copy files. Date: 8 Mar 1998 00:53:21 GMT Organization: EuroNet Internet Lines: 27 Message-ID: <6dsq61$hb2@news.euro.net> NNTP-Posting-Host: breda30.pstn01.concepts.nl To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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" ); if( !ffile || !tfile ) return false; while( !feof( ffile )) { haveread = fread( buffer, 1, maximumread, ffile ); fwrite( buffer, 1, haveread, tfile ); } fclose( ffile ); fclose( tfile ); return true; } Foxe foxe AT poboxes DOT com