//
// cerr example
//
#include<iostream>
#include<fstream>
void main ( )
{
usingnamespace std;
// open the file "file_name.txt"
// for reading
ifstream in("file_name.txt");
// output the all file to stdout
if ( in )
cout << in.rdbuf();
else
// if the ifstream object is in a bad state
// output an error message to stderr
cerr << "Error while opening the file" << endl;
}
// if the ifstream object is in a bad state
// output an error message to stderr
Where is stderr? Where cerr output the error message? How can i grab it since its not printed to a place that a programmer specified such as file or screen...
Note: i got this code from the internet from a good source. I did not test it yet