How it’s done
- Continue to use cout<< in your code
- in an online environment, we globally modify the behavior of the cout object to achieve the desired functionality
cout (and in general, all objects of type "ostream") are only the formatting engine. They enlist the services of another object (of type "streambuf") to handle their formatted output.
We can provide a new "streambuf" object to be used by cout which has the functionality which we want. This is a standard procedure in C++, not some "dirty trick".
if ( file_is_open) return -1;
sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number);
if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL )
cerr << "file not opened " << strerror(errno) << endl;
// cout << "opened file " << ctrlbuf->current_filename << endl;
int ndd_control::close_file()
if ( !file_is_open) return -1;
if ( file_is_open) return -1;
sprintf( ctrlbuf->current_filename, ctrlbuf->filerule, run_number);
if ( (the_file = fopen(ctrlbuf->current_filename, "w") )==NULL )
cerr << "file not opened " << strerror(errno) << endl;
// cout << "opened file " << ctrlbuf->current_filename << endl;
int ndd_control::close_file()
if ( !file_is_open) return -1;
*ASADMS means “All Singing, All Dancing Messaging System”