From: Jason Green Newsgroups: comp.os.msdos.djgpp Subject: Re: C compiler inserts 0x0d before 0x0a? Date: Sun, 30 Jul 2000 12:08:44 +0100 Organization: Customer of Energis Squared Lines: 17 Message-ID: References: <397BFC7C DOT 111C0896 AT ethernet DOT com> <8lgufv$69m$1 AT sun27 DOT hrz DOT tu-darmstadt DOT de> <3983639C DOT 16732F85 AT ethernet DOT com> NNTP-Posting-Host: modem-34.vanadium.dialup.pol.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news6.svr.pol.co.uk 964955433 1086 62.136.22.34 (30 Jul 2000 11:10:33 GMT) NNTP-Posting-Date: 30 Jul 2000 11:10:33 GMT X-Complaints-To: abuse AT theplanet DOT net X-Newsreader: Forte Agent 1.7/32.534 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Jim Smith wrote: > > Open with O_BINARY to circumvent. > > Thanks to those who replied with the above suggestion. However, it still > does not work. As shown below, I simply added the O_BINARY word to the file > open, but the extra bytes (0x0d) are still inserted into the output file. > I'm lost. Thanks for any help. Try deleting junkfile before running the program, or open with O_TRUNC instead of O_CREAT. Your original program will produce a 7-byte file. With O_BINARY, the program writes only 5 bytes but if the file already exists it won't be truncated. "info libc a open" lists the options and their meanings.