www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/09/03/05:52:14

From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Problem with fstreams...
Date: 29 Aug 1997 08:53:37 GMT
Organization: The National Capital FreeNet
Lines: 31
Message-ID: <5u62mh$9l6@freenet-news.carleton.ca>
References: <Pine DOT SGI DOT 3 DOT 93 DOT 970829111108 DOT 28565A-100000 AT gibson>
Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire)
NNTP-Posting-Host: freenet2.carleton.ca
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Orlando Andico (orly AT gibson DOT eee DOT upd DOT edu DOT ph) writes:
> On 25 Aug 1997, Adam W Lee wrote:
> 
>> : it is more helpful to specify the exact problem and give the exact code
>> : that produces it. without that, all others can do is guess.
>> 
>> : so, i am guessing that you are dealing with binary files, but opening
>> : them in text mode. if this is the case, then read the fstream docs on
>> : how to open the files in binary mode.
>> 
>> I did specify the exact problem, it quits copying halfway through!  And I
>> also provided source...  Like I said, though, it works great under Unix.
> 
> that's exactly it. unix treats all files as binary, but dos has a text or
> "cooked" mode, and binary mode. default is cooked mode. when dos sees a ^z
> character (ascii 26) it treats that as end-of-file and stops. 
> 
> you have to add a "b" to your fopen, e.g. fopen ("file", "rb") in order to
> get the binary behavior of unix under dos ("b" does nothing under unix).
> if you're using open() you have to pass it the O_BINARY flag.

And in C++, ios::binary in the streap initializing.

(What is ios::binary really? ios must be a class or something. Or maybe
it's an enum?)
--
    .*.  Where feelings are concerned, answers are rarely simple [GeneDeWeese]
 -()  <  When I go to the theater, I always go straight to the "bag and mix"
    `*'  bulk candy section...because variety is the spice of life... [me]
Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh

- Raw text -


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