www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/22/12:14:02

From: klr03 AT banshee DOT cs DOT uow DOT edu DOT au (Karl Leslie Rudd)
Newsgroups: comp.os.msdos.djgpp
Subject: A quirk of fstream?
Date: 22 Sep 1996 20:49:36 +1000
Organization: University of Wollongong, NSW, Australia.
Lines: 44
Message-ID: <5235k0$ful@banshee.cs.uow.edu.au>
NNTP-Posting-Host: banshee.cs.uow.edu.au
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

This is my first post to this newsgroup, however I've been reading it for a
while.

Could someone please tell me if this is just a quirk of the GNU iostreams
or if it is in fact "standard" behaviour.

When I compile and run the following program with gxx I get:

Sorry, can't open file.

However if I compile and run the program on the university's system using
either the Sun CC or the GNU g++ compilers, it works fine.

It seems that with the DJGPP version if the file does not exist and you
include the ios::in flag at all, it fails. (or am I missing something)

#include <iostream.h>
#include <fstream.h>

int main()
{
	fstream File;

	File.open("temp.txt", ios::in | ios::out);
	if(!File.good())
	{
		cerr << "Sorry, can't open file." << endl;
		return 1;
	}

	return 0;
}

BTW Many thanks to DJ Delorie and co. for a GREAT compilier suite.

-------------------------------------------------+------------------------
 "Life is a song we must sing with our days,     |
  A poem with meaning more than words can say,   |      Karl Rudd
  A painting with colours no rainbow can tell,   |
  A lyric that rhymes either heaven or hell."    |   klr03 AT uow DOT edu DOT au
   - Michael Card, Poiema, The Poem of Your Life |
-------------------------------------------------+------------------------

- Raw text -


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