🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1049

fstream/open()/close()/can'tfindfile

#1049
From: F r e D S l a m A
Date: Mon, 12 Oct 1992 14:23
58 lines
1788 bytes
	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
 ===============================================================================
Technical Details
Message-ID: <1992Oct12.142303.22088@newshost.unh.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!spool.mu.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!kepler.unh.edu!fgs

Show Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!convex!darwin.sura.net!spool.mu.edu!agate!usenet.ins.cwru.edu!magnus.acs.ohio-state.edu!cis.ohio-state.edu!kepler.unh.edu!fgs
From: fgs@kepler.unh.edu ( F r e D  S l a m A )
Subject: fstream/open()/close()/can'tfindfile
Message-ID: <1992Oct12.142303.22088@newshost.unh.edu>
Sender: gnulists@ai.mit.edu
Organization: University of New Hampshire  -  Durham, NH
Distribution: gnu
Date: Mon, 12 Oct 1992 14:23:03 GMT
Approved: bug-g++@prep.ai.mit.edu
Lines: 59