Input File Streams in Microsoft Visual C++ 5.0

Microsoft Visual C++ seems to behave differently when opening input file streams than other C++ compilers.

The following statements, for example, should display an error message if the input file is not found, but Microsoft C++ simply creates a new empty file called myfile.txt:

	ifstream infile( "myfile.txt", ios::in );
	if( !infile ) cerr << "File not found";

Instead, you must use the nocreate flag to get the error message to display:

	ifstream infile( "myfile.txt", ios::in | ios::nocreate );
	if( !infile ) cerr << "File not found";