Path: utzoo!attcan!uunet!snorkelwacker!apple!gateway.qm.apple.com!sean_parent.snarkmail_l_z From: sean_parent.snarkmail_l_z@gateway.qm.apple.com (Sean Parent) Newsgroups: comp.sys.mac.programmer Subject: Re: simple C Problem Message-ID: <10630@goofy.Apple.COM> Date: 9 Oct 90 18:28:19 GMT References: <1268@beguine.UUCP> Sender: usenet@Apple.COM Organization: Apple Computer, Inc. Lines: 30 In article <1268@beguine.UUCP> Eliot.Henry@samba.acs.unc.edu (BBS Account) writes: > I have a routine I wrote in pascal that reads and writes blocks from > a floppy drive. The problem is that when I converted it to C it doesn't > work. Yes, strange but true. It gives an error -50 every so often then > consistantly has trouble reading the next 65 or 66 sectors (there is a loop > that is writing to the entire disk) This is probably an embaressingly simple > problem. Any help would be greatly appreciated here is the code I have: > In article <1268@beguine.UUCP> Eliot.Henry@samba.acs.unc.edu (BBS Account) writes: > > char thebuffer[512]; > In article <1268@beguine.UUCP> Eliot.Henry@samba.acs.unc.edu (BBS Account) writes: > > /* Load the array with 0 bits (ascii character zero) */ > for (i=1; i<=512; i++) > thebuffer[i]=0; This is a commen problem with pascal programers converting to C. thebuffer is an array containing 512 items but is indexed form 0 to 511. The for loop here will write off the end of the array. Sean Parent "Quality unattainable in a reasonable amount of time."