www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/12/12/20:16:05

Date: Tue, 12 Dec 1995 13:23:07 -0500
To: djgpp AT sun DOT soe DOT clarkson DOT edu
From: dmont AT tradeit DOT com (Dave Montgomery)
Subject: Re: Strange bug using 'fwrite'

>   f2 = fopen("out.2", "w");
                         ^
First, just a "w" defaults to "wt" (text mode).  In DOS new lines (0x0d)
are replaced with a carriage return/line feed combination (0x0d 0x0a).

In UNIX new lines are simply new lines (profound ain't it).

So, if you are indeed writing arbitrary bytes to the file open it
with mode "wb" (binary).  This will work for both DOS and UNIX.

Regards,
   Dave Montgomery
---
 .--===========.             =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 =.--=========.-                     Dave Montgomery
 ==.--=======.--                 Versus Technologies Inc.
 ===.--=====.---                181 Bay Street, Suite 3810
 ====.--===.----                 Toronto, Ontario M5J 2T3
 =====.--=.-----	     Ph 214-1960 x5773  Fax 864-3918
 ======.-.------                E-mail: dmont AT tradeit DOT com
 =======.-------             =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 V  E  R  S  U  S

- Raw text -


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