Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!rutgers!ucsd!ucbvax!POSTGRES.BERKELEY.EDU!dillon From: dillon@POSTGRES.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga.tech Subject: Re: fopen() modes in Lattice C Message-ID: <8811280644.AA14253@postgres.Berkeley.EDU> Date: 28 Nov 88 06:44:14 GMT Sender: daemon@ucbvax.BERKELEY.EDU Lines: 29 :> fopen(temp, "wb"); : :The `b' stands for binary (versus `t' text) and does no translation on :your file stream. In text mode, CR-LF sequences are translated to NL :characters on input. On output, the reverse occurs: NL's are translated :to CR-LF's. : :NOTE: This information was neither in K&R nor my Manx (Compiler :-) ) C. : I looked it up in Microsoft C and I've used this mode in UNIX before. On an IBM-PC, yes. The IBM-PC uses the CR-LF combinations instead of just an LF. Since STDIO defines the 'new line' to be just an LF, C implementations on the IBM's must filter out the CR's when reading and add them when writing. Unfortunetly, the idiots (not just Lattice, but essentially ALL the IBM-PC implementations) made the default 'text'. A simple fopen("blah", "r") on an IBM *assumes* translation, which is stupid. The default can usually be changed by modifying a global variable, but it doesn't make porting much easier. Even worse, the low-level IO routines as implemented on most C compilers on IBM's also do translation! On the Amiga, no. There is no translation done. There had better NOT be any translation! On the Amiga a 'new line' is a single LF which is compatible with STDIO (i.e. UNIX, which was what stdio was built on). A simple fopen("blah", "r") on the Amiga is 'binary', and there is no difference between binary and text. -Matt