Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!wuarchive!decwrl!bacchus.pa.dec.com!shlump.nac.dec.com!mountn.dec.com!minow From: minow@mountn.dec.com (Martin Minow) Newsgroups: comp.sys.mac.programmer Subject: Re: Carriage Returns in ascii files Message-ID: <1804@mountn.dec.com> Date: 31 Jul 90 02:50:53 GMT References: <14711@csli.Stanford.EDU> Reply-To: minow@bolt.enet.dec.com (Martin Minow) Organization: Digital Equipment Corporation Lines: 23 In article <14711@csli.Stanford.EDU> francis@csli.stanford.edu (Dave Francis) asks about writing a carriage return to a line of text using FSWrite: > >len = 1L; >err = FSWrite(refNum, &len, "\n"); > Unfortunately, this didn't work. C programs on the Macintosh live in two "universes" -- the Mac universe and the (Ansi) C universe. If you write for the C universe, your program printf's '\n' and the C run-time library does whatever is needed to create a new line. This varies -- wildly -- on the systems that support C. On the Macintosh, a newline is signalled by a character, Hex 0D (Octal 015). Thus, the "proper" way to write a Mac-style carriage return using FSWrite is err = FSWrite(refNum, &len, "\015"); but most of us write FSWrite(... "\r") which isn't quite correct if you're into nit-picking, but works anyway. In any case, you should still use "\n" if you're writing a file created by fopen(). Martin Minow minow@bolt.enet.dec.com