🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.lib.bug
Article #297

[fgs@kepler.unh.edu : fstream/open()/close()/can'tfindfile]

#297
From: Brendan Kehoe
Date: Wed, 14 Oct 1992 02:04
68 lines
2107 bytes
------- Start of forwarded message -------
From: fgs@kepler.unh.edu ( F r e D  S l a m A )
Subject: fstream/open()/close()/can'tfindfile
To: bug-g++@prep.ai.mit.edu
Date: Mon, 12 Oct 1992 14:23:03 GMT
Newsgroups: gnu.g++.bug
Organization: University of New Hampshire  -  Durham, NH

	Known bug? It would seem so, but don't know, so I am posting anyway:

	This code:



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

const fileCnt = 5;
char *fileTabl [fileCnt] = {"file0", "file1", "file2", "file3", "file4"};


main()
{
	ifstream inFile;
	char c;

	for (int i=0; i < fileCnt; i++)
	{

		inFile.open(fileTabl[i], ios::in);


//		cerr << "File: " << inFile;
		if ( inFile.fail() )
		{
			cerr << "File " << fileTabl[i] << " can't be opened" 
							<< endl;
		}
		else
		{
			while ( inFile.get (c))
			{
				cout << c;
			}
		
			cout << endl;
			inFile.close();
		}
	}
}
- -------------------------

	.. will only process the first file, and return file open
	failure on subsequent opens... Only on g++. I ran the same
	code though the AT&T 2.1.0 compiler and it worked fine. This example
	can also be found in Stanley B. Lippman C++ Primer.



													-Fred
- -- 
 ===============================================================================
 Frederick G. Slama at >>>>>>>>>>>>>| slama@ctron.com (just a CO-OP)
 The University of New Hampshire <<<| fgs@kepler.unh.edu   F_SLAMA@unhh.unh.edu
 ===============================================================================

------- End of forwarded message -------
Technical Details
Message-ID: <9210140204.AA00138@cygnus.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!brendan

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.lib.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!cygnus.com!brendan
From: brendan@cygnus.com (Brendan Kehoe)
Subject: [fgs@kepler.unh.edu : fstream/open()/close()/can'tfindfile]
Message-ID: <9210140204.AA00138@cygnus.com>
Sender: gnulists@ai.mit.edu
Reply-To: brendan@cygnus.com
Organization: GNUs Not Usenet
Distribution: gnu
Date: Wed, 14 Oct 1992 02:04:56 GMT
Approved: bug-lib-g++@prep.ai.mit.edu
Lines: 69