#include <fstream>
  void open( const char *filename );
  void open( const char *filename, openmode mode = default_mode );

The function open() is used with file streams. It opens filename and associates it with the current stream. The optional io stream mode flag mode defaults to ios::in for ifstream, ios::out for ofstream, and ios::in|ios::out for fstream.

If open() fails, the resulting stream will evaluate to false when used in a Boolean expression. For example:

 ifstream inputStream;"file.txt");
 if( !inputStream ) {
   cerr << "Error opening input stream" << endl;