home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / os / os2 / programm / 3825 < prev    next >
Encoding:
Internet Message Format  |  1992-07-27  |  1.6 KB

  1. Path: sparky!uunet!darwin.sura.net!jvnc.net!rutgers!cmcl2!panix!os2man
  2. From: os2man@panix.com (Larry Salomon Jr.)
  3. Newsgroups: comp.os.os2.programmer
  4. Subject: Re: fopen(f,"r") vs fopen(f,"rb") what's the diff?
  5. Message-ID: <1992Jul27.222531.10668@panix.com>
  6. Date: 27 Jul 92 22:25:31 GMT
  7. References: <=!jmdvp.feustel@netcom.com> <92Jul25.163359.18069@acs.ucalgary.ca> <1992Jul25.175848.29166@unixg.ubc.ca>
  8. Organization: PANIX Public Access Unix, NYC
  9. Lines: 31
  10.  
  11. In <1992Jul25.175848.29166@unixg.ubc.ca> ochealth@unixg.ubc.ca (ochealth) writes:
  12.  
  13.  
  14.  
  15. >A number of UNIX programs I have ported to OS/2 using emx or gcc
  16. >choke on binary files, unless I modify them.
  17.  
  18. >for example:
  19. >f = fopen(name,"r") must be changed to f=fopen(name,"rb")
  20. >etc.
  21.  
  22. >I was wondering just what happens when you don't open as binary.
  23. >Will it return EOF when it sees ^Z or what?
  24.  
  25. >This is sort of troubling to me, since EMX is desing to make porting UNIX easier
  26.  
  27. >Was fopen changed to make it more compatible with OS/2 or what. From what I've
  28. >read "r" and "rb" are handled the same in UNIX.
  29.  
  30. "r" and "rb" are a world apart, although the difference is slight.  "Text mode"
  31. implies that CR-LF pairs are translated to LF on reads and vice-versa on 
  32. writes.  This is due to the hardware, I believe, requiring the CR and LF
  33. to perform a "new line" operation.  Additionally - and I could be wrong here -
  34. text mode does return EOF when Ctrl-Z is encountered, while binary mode does
  35. not.
  36.  
  37. -- 
  38. Cheers,
  39. Q
  40. -----------------------------------------------------------------------
  41. "If you still choose not to decide,   | "My other account is in the
  42.