delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/11/21/00:22:28

From: "sl" <sl AT psycode DOT com DOT REMOVE_THIS>
Newsgroups: comp.os.msdos.djgpp
Subject: DJGPP 2.01 / GCC 2.8.1 implementation flaw
Date: Fri, 20 Nov 1998 23:23:06 -0500 (EST)
Organization: Posted via Supernews, http://www.supernews.com - Discussions start here!
Lines: 25
Message-ID: <fycflpbqrpbz.f2r86i0.pminews@nntp.generation.net>
NNTP-Posting-Host: 205.205.70.87
Mime-Version: 1.0
X-Trace: 911625392 ZCZSLWF4G4657CDCDC usenet80.supernews.com
X-Complaints-To: newsabuse AT supernews DOT com
X-Newsreader: PMINews 2.00.1205 For OS/2
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hello,

	According to my trusty book here, ofstream defaults to using
ios::trunc when opening file.. Meaning all output-files should be truncated
by default. My problem is that when I don't trust GCC and use the following
statement:

ofstream someFile("hello.txt", ios::trunc);

	Looking at the implementation  I found the problem.. The constructor
defaults "mode" to "ios::out" .. when I use ios::trunc in place and override
the default, the file knows it should open in truncate mode, but it does not
know to open in output mode. I believe this is an implementation fault: no
matter what the programmer specifies, ofstream should ALWAYS use ios::out and
when someone chooses to do

ofstream someFile("hello.txt", ios::trunc);

	like me, it should know that really means ios::out|ios::trunc.. After
all, that *is* the definition of the ofstream class. Any suggestions,
comments?

Gili


- Raw text -


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