Hi.
-=> Quoting Steve Johnson to All <=-
SJ> Help!
SJ> However, I've caught a little snag. I tried to copy a file 906,294
SJ> bytes in size and the program only copies 201 bytes of it.
Let me see.......
SJ> If you can take a look, please help! Tell me all of your thoughts!
SJ> #include
SJ> #include
SJ> const bufsize = 500000L;
First of all this buffer size is too big. Welp it depends which
compiler you use(if u use watcom's or any other protected mode
compiler it won't do any problems, but if u use TC it might do some
problems because of 64K limit. I would recommend you to change it to
sth like 60,000)
SJ> int copyfile (char *src, char *dst)
SJ> {
SJ> FILE *srcfile;
SJ> FILE *dstfile;
SJ> void *bufptr;
SJ> size_t amountread;
SJ> size_t amountwritten;
SJ> if ((bufptr = malloc (bufsize)) == NULL)
SJ> {
SJ> perror ("Error:");
SJ> return 1;
SJ> }
SJ> srcfile = fopen (src, "r");
Here is the problem! In this line you are trying to open *TEXT* file
for reading. So if you are trying to copy binary files this program
won't work.
To solve this problem replace "r" with "rb".
And same in output file instead "w" with "wb".
Hope it helps.
bye bye
ÄÄÄ SuperED¡T v1.91 UNREGÿ
... Backup not found: (A)bort (R)etry (S)lap nearest innocent bystander.
---
---------------
* Origin: þ Fire Storm BBS þ +972-3-5368921 þ 22:00-8:00 þ 33k þ (2:403/202)
|