www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/08/28/23:15:49

Date: Fri, 29 Aug 1997 11:14:35 +0800 (GMT)
From: Orlando Andico <orly AT gibson DOT eee DOT upd DOT edu DOT ph>
To: Adam W Lee <adalee AT sendit DOT sendit DOT nodak DOT edu>
cc: djgpp AT delorie DOT com
Subject: Re: Problem with fstreams...
In-Reply-To: <5trdmc$d79$2@news.sendit.nodak.edu>
Message-ID: <Pine.SGI.3.93.970829111108.28565A-100000@gibson>
MIME-Version: 1.0

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.

sorry if i repeat what someone else might have said, but i don't have your
code fragment around so i can't see if you already did that.
 
-------------------------------------------------------------------
Orlando Alcantara Andico
WWW:   http://www2.mozcom.com/~orly/         Email: orly AT mozcom DOT com
ICBM:  14 30 00 N  120 59 00 E               POTS:  (+632) 932-2385

- Raw text -


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