delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/07/11/20:15:16.1

From: Jack Klein <jackklein AT spamcop DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: read() also broken
Message-ID: <ihppktsbj9hod82d5ib2ak7ksnfc514cur@4ax.com>
References: <Pine DOT GSO DOT 4 DOT 33 DOT 0107111652110 DOT 4160-100000 AT brahms>
X-Newsreader: Forte Agent 1.8/32.548
MIME-Version: 1.0
Lines: 26
Date: Wed, 11 Jul 2001 23:52:28 GMT
NNTP-Posting-Host: 12.84.2.210
X-Complaints-To: abuse AT worldnet DOT att DOT net
X-Trace: bgtnsc06-news.ops.worldnet.att.net 994895548 12.84.2.210 (Wed, 11 Jul 2001 23:52:28 GMT)
NNTP-Posting-Date: Wed, 11 Jul 2001 23:52:28 GMT
Organization: AT&T Worldnet
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Wed, 11 Jul 2001 16:53:25 -0500 (CDT), Jeff Bastian
<bastian AT hc DOT ti DOT com> wrote in comp.os.msdos.djgpp:

> 
> I just modified my code to use read() instead of fread() as a work-around,
> but read() demonstrates the same problem of skipping over the 0x0d
> character.

In fact it is not broken but following the behavior REQUIRED by both
ANSI/ISO C and ANSI/ISO C++ for text files.  At least fread() is,
since neither language standard defines read().

If you do the same thing on a Macintosh every byte with the value 0x0d
in a file will be read by your program as 0x0a.

Do not use the default file open mode (text mode) unless you are
reading text files.  Do use the binary file open modes with files
where you want to read or write binary data.

-- 
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++ ftp://snurse-l.org/pub/acllc-c++/faq

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019