Article View: comp.os.os2.programmer
Article #515Re: fopen(f,"r") vs fopen(f,"rb") what's the diff?
From: Larry Salomon Jr.
Date: Mon, 27 Jul 1992 22:25
Date: Mon, 27 Jul 1992 22:25
31 lines
1645 bytes
1645 bytes
In <1992Jul25.175848.29166@unixg.ubc.ca> ochealth@unixg.ubc.ca (ochealth) writes: >A number of UNIX programs I have ported to OS/2 using emx or gcc >choke on binary files, unless I modify them. >for example: >f = fopen(name,"r") must be changed to f=fopen(name,"rb") >etc. >I was wondering just what happens when you don't open as binary. >Will it return EOF when it sees ^Z or what? >This is sort of troubling to me, since EMX is desing to make porting UNIX easier >Was fopen changed to make it more compatible with OS/2 or what. From what I've >read "r" and "rb" are handled the same in UNIX. "r" and "rb" are a world apart, although the difference is slight. "Text mode" implies that CR-LF pairs are translated to LF on reads and vice-versa on writes. This is due to the hardware, I believe, requiring the CR and LF to perform a "new line" operation. Additionally - and I could be wrong here - text mode does return EOF when Ctrl-Z is encountered, while binary mode does not. -- Cheers, Q ----------------------------------------------------------------------- "If you still choose not to decide, | "My other account is in the
Technical Details
Message-ID:
<1992Jul27.222531.10668@panix.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!darwin.sura.net!jvnc.net!rutgers!cmcl2!panix!os2manReferences:
<=!jmdvp.feustel@netcom.com> <92Jul25.163359.18069@acs.ucalgary.ca> <1992Jul25.175848.29166@unixg.ubc.ca>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!darwin.sura.net!jvnc.net!rutgers!cmcl2!panix!os2man From: os2man@panix.com (Larry Salomon Jr.) Newsgroups: comp.os.os2.programmer Subject: Re: fopen(f,"r") vs fopen(f,"rb") what's the diff? Message-ID: <1992Jul27.222531.10668@panix.com> Date: 27 Jul 92 22:25:31 GMT References: <=!jmdvp.feustel@netcom.com> <92Jul25.163359.18069@acs.ucalgary.ca> <1992Jul25.175848.29166@unixg.ubc.ca> Organization: PANIX Public Access Unix, NYC Lines: 31