Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!tektronix!tekcrl!tekgvs!toma From: toma@tekgvs.LABS.TEK.COM (Tom Almy) Newsgroups: comp.sys.ibm.pc Subject: Re: using files in C on the IBM PC Message-ID: <5140@tekgvs.LABS.TEK.COM> Date: 15 May 89 15:12:23 GMT References: <110@sol.bucknell.edu> <1989May11.203209.9152@ziebmef.uucp> Reply-To: toma@tekgvs.LABS.TEK.COM (Tom Almy) Organization: Tektronix, Inc., Beaverton, OR. Lines: 36 In article <1989May11.203209.9152@ziebmef.uucp> stephen@ziebmef.UUCP (Stephen M. Dunn) writes: > > Okay, most or all of the common C compilers for DOS operate in >"cooked" mode by default on file accesses. This means that they treat >^Z (otherwise known as EOF) as the end-of-file marker, and they will >play around with CRs and LFs. There is another mode of file access >known as "raw" mode to DOS people and "binary" mode to C people. Instead >of saying R or W as your file access mode, say RB or WB instead and >DOS will stop playing with your file. You can then read or write whatever >character codes your heart desires without fear of intervention from >DOS. Actually there are two different features (?) being discussed here -- "raw" vs "cooked" and "ascii" vs "binary". "ascii" vs "binary" is an artifact of C's treatment of end of lines. DOS denotes end of lines with a CR LF pair, while C uses a single LF character. When a file is opend "ascii" (usually the default, but can be forced by opening "ra" or "wa" in most C libraries) CR's are stripped on input and prepended to any LF's on output. "raw" vs "cooked" is a DOS driver feature (also in UNIX). If, for instance, the keyboard is "raw" control-C characters will always be passed to the program rather than treated as special case interrupt character. Also display output speed is improved in RAW mode because the keyboard buffer does not need to be checked, and certain drivers (such as NANSI.SYS or FANSI-CONSOLE) can work more efficiently. If you are doing graphics to a printer, you need to set raw mode. I'm not sure if the various C library setmode() routines affect just "ascii" vs "binary" or also change "raw" vs "cooked". I always issue the DOS calls directly to set raw mode. Tom Almy toma@tekgvs.labs.tek.com Standard Disclaimers Apply