Message-ID: <3983639C.16732F85@ethernet.com> From: Jim Smith X-Mailer: Mozilla 4.73 [en] (Win98; I) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.os.msdos.djgpp Subject: Re: C compiler inserts 0x0d before 0x0a? References: <397BFC7C DOT 111C0896 AT ethernet DOT com> <8lgufv$69m$1 AT sun27 DOT hrz DOT tu-darmstadt DOT de> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 49 Date: Sat, 29 Jul 2000 16:07:09 -0700 NNTP-Posting-Host: 216.101.0.2 X-Complaints-To: abuse AT pacbell DOT net X-Trace: news.pacbell.net 964911908 216.101.0.2 (Sat, 29 Jul 2000 16:05:08 PDT) NNTP-Posting-Date: Sat, 29 Jul 2000 16:05:08 PDT Organization: SBC Internet Services To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Uwe Bonnes wrote: > Welcome to the wonderfull world of DOS CR/LF linebreaks. > > If you write out a text file on dos, you will get those CR/LF endings. > > 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. -------------------------- Start of Program -------------------------------------- #include #include #include #include #include int main() { char myfile[] = "junkfile"; int out; char buf[100]; if ((out = open(myfile, O_CREAT | O_WRONLY | O_BINARY )) < 0 ) { perror(myfile); exit(1); } buf[0] = 0x61; buf[1] = 0x0a; buf[2] = 0x62; buf[3] = 0x0a; buf[4] = 0x63; write(out, buf, 5); close(out); exit(0); }