delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2002/12/05/19:00:25

From: "J. L." <jose DOT sanchezga AT imss DOT gob DOT mx>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Files fread() in and fread() out get garbled
Date: Thu, 05 Dec 2002 17:53:44 -0600
Lines: 45
Message-ID: <h5mvuu4q16qefkd7soj7svfj8o0m1eopf5@4ax.com>
References: <asok7c$tj8$1 AT news7 DOT svr DOT pol DOT co DOT uk>
NNTP-Posting-Host: 200.34.143.17
Mime-Version: 1.0
X-Trace: fu-berlin.de 1039132462 30678250 200.34.143.17 (16 [143309])
X-Newsreader: Forte Agent 1.92/32.572 trialware
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Thu, 5 Dec 2002 22:33:00 -0000, "Eric" <eric AT replytogroup DOT net>
wrote:

>
>Hello. I've been staring at my program for an hour and can't find the bug.
>Hope you can help :-)
>
>My code is supposed to break up a large file into several small files for
>transfer on floppy disks, then re-assemble the large file from the parts
>given the -r command. Trouble is, the re-assembled file, although the right
>size, is messed up in some way: whenever I split a large .exe, for example,
>re-assemble it and then run it, all sorts of weirdness occurs.
>
>PS: I'm a newbie and this is my most ambitious program ever, so please go
>easy :-)
>
[snip code]

I see this message also in clc. There are 1 useful advice from Jim
<sorry AT not DOT com> about your split function.

[snipet reproduced from clc]

>>        unit = FLOPPY_CAPACITY;
>>

>	{
	char *tbuffer = buffer;
>>        while (size) {
>>                *fname = *name++;
>>              f = fopen(fname, "wb");
>>                if (f == NULL) {
>>                        error(FILE_IO);
>>                }
>>                puts("Writing...");

>>            -    bytes = fwrite(buffer, 1, unit, f);
	     +	bytes = fwrite(tbuffer, 1, unit, f)
	     +  tbuffer += FLOPPY_CAPACITY;

You are allways writing to yours *n* diskettes the same first
FLOPPY_CAPACITY bytes of file to split. Change the code acording Jim's
advice. 

J. L.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019