www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/12/12/21:27:56

Xref: news-dnh.mv.net comp.os.msdos.djgpp:3791
Path: news-dnh.mv.net!mv!news.NH.Destek.Net!news2.net99.net!news.cais.net!ringer.cs.utsa.edu!swrinde!newsfeed.internetmci.com!bloom-beacon.mit.edu!senator-bedfellow.mit.edu!davis
From: davis AT space DOT mit DOT edu (John E. Davis)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Strange bug using 'fwrite'
Date: 11 Dec 1995 09:08:25 GMT
Organization: Center for Space Research
Lines: 18
References: <4agbj6$1vm AT bmerhc5e DOT bnr DOT ca>
Reply-To: davis AT space DOT mit DOT edu
Nntp-Posting-Host: wiwaxia.mit.edu
To: djgpp AT sun DOT soe DOT clarkson DOT edu
Dj-Gateway: from newsgroup comp.os.msdos.djgpp

On 11 Dec 1995 04:20:54 GMT, Chris Butler <cbutler AT bnr DOT ca>
wrote:
 :    I was coding away this weekend when the following bug
 : stopped me dead.
[...]
 :    f2 = fopen("out.2", "w");
 
The problem is here.  You need to open the file in binary mode ("wb").

[...]
 :    Also, I messed around with the initialization of the 'extra_bytes'
 : in other tests - the '0d' always seems to follow the '09'.

Since you opened it in text mode, whenever you write a line feed (0xa), it
gets mapped into CRLF (0xd 0xa).

--John

- Raw text -


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