🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: gnu.g++.lib.bug
1 messages
1 total messages Started by Brendan Kehoe Wed, 14 Oct 1992 02:04
[fgs@kepler.unh.edu : fstream/open()/close()/can'tfindfile]
#297
Author: 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 -------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads