For some reason the code is not printing the error string in the output screen of the operating system. Go figure? This code is directly out of the book.


ofstream fileout;
ifstream filein;

void main()
	char file[20];		//you must type in filename and extension
	char inChar;

	cout << "What is the name of the file you want to see? ";
	cin >> file;, ios::in);
	         cout<<"\n\n*** That file does not exist ***\n";	//not displaying for some reason
	}	while(filein.get(inChar))
		cout << inChar;

<< moderator edit: added [code][/code] tags >>

Recommended Answers

All 2 Replies

It sounds like the stream isn't getting flushed. That's not correct behavior because calling exit() will flush all output streams with unwritten data. Just for grins, try changing cout to cerr and see what happens. cerr has the unitbuf flag set by default, so it should flush the stream after every operation. If that works then the compiler isn't predictable enough to be useful and you should get a newer version. Visual C++ 2005 Express Beta 2 is free for download, and conforms to the C++ standard very well. Dev-C++ is also a good conforming compiler, but the IDE is lacking in my opinion.

Topic moved to the C++ section.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.