Newsgroups: comp.lang.c Path: utzoo!telly!problem!druid!darcy From: darcy@druid.uucp (D'Arcy J.M. Cain) Subject: Re: writing a file byte by byte Message-ID: <1991Mar1.033511.17234@druid.uucp> Organization: D'Arcy Cain Consulting, West Hill, Ontario References: <9527@hub.ucsb.edu> Distribution: comp Date: Fri, 1 Mar 91 03:35:11 GMT In article <9527@hub.ucsb.edu> 6600bori@ucsbuxa.ucsb.edu (Boris Burtin) writes: >I'm using Turbo C 2.0 and DOS 3.3, and I'm attempting to write 8166 bytes >to a file (for those who know what I'm talking about, this is a MIDI sysex >file). By the MIDIEX standard, this file should be 8166 bytes long, but >when I write it, it turns out to be some 8300 or so bytes long. Does anyone >know how to solve this problem? Thanks... There really isn't much information here but I'll make a guess. How many of the bytes that you are writing happens to be 0x0a? By any chance 234? maybe you are opening the file as "w" instead of "wb". The default with MSDOS is to open the file in text mode and that means that line feeds are converted to CR/LF pairs. If you are writing binary data you should always open a file in binary mode even if you are working on a Unix system or some other system where this doesn't matter. It saves you heartaches when you decide to port the code and also serves as sort of a comment about how you intend to treat the data in the file. Note that on systems where the "b" flag is not needed the flag is ignored. If this is not your problem please give more details and if possible some sample code that exhibits the problem. -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | There's no government West Hill, Ontario, Canada | like no government! +1 416 281 6094 |