### cerr and clog

The cerr and clog streams direct output to standard error. cerr provides unbuffered output, while clog provides buffered output. The following example checks for a division by zero condition. If one occurs, a message is sent to standard error.

    /**
     ** Check for a division by zero condition.
     ** If one occurs, a message is sent to standard error.
     **/

    #include <iostream.h>
    void main()
    {
          double val1, val2;
          cout << "Divide Two Values" << endl;
          cout << "Enter two numeric values: " << endl;
          cin >> val1 >> val2;
          if (val2 == 0 )
          {
                 cerr << "The second value must be non-zero" << endl;
          } else
                 cout << "The answer is " << val1 / val2 << endl;
    }