.\" ident @(#)cerr.3 .\" Standard Template Library .\" $$RW_INSERT_HEADER "slyrs.man" .TH cerr 3C++ "02 Apr 1998" "Rogue Wave Software" "-" .ce2 Standard C++ Library Copyright 1998, Rogue Wave Software, Inc. .SH NAME \f2cerr\fP \ - Controls output to an unbuffered stream buffer associated with the object \f2stderr\fP declared in \f2\fP. .SH SYNOPSIS .br #include .br extern ostream cerr; .br ostream cerr; .SH DESCRIPTION The object \f2cerr\fP controls output to an unbuffered stream buffer associated with the object \f2stderr\fP declared in \f2\fP. By default, the standard C and C++ streams are synchronized, but you can improve performance by using the \f2ios_base\fP member function \f2synch_with_stdio\fP to desynchronize them. .SH FORMATTING The formatting is done through member functions or manipulators. See \f2cout\fP or \f2basic_ostream\fP for details. .SH EXAMPLE .br // .br // cerr example .br // .br #include .br #include .br .br void main ( ) .br { .RE .RS 1 using namespace std; .RE .RS 0 .RE .RS 2 // open the file "file_name.txt" .br // for reading .RE .RS 1 ifstream in("file_name.txt"); .br .RE .RS 2 // output the all file to stdout .RE .RS 1 if ( in ) .RE .RS 3 cout << in.rdbuf(); .RE .RS 1 else .RE .RS 4 // if the ifstream object is in a bad state .br // output an error message to stderr .RE .RS 3 cerr << "Error while opening the file" << endl; .RE .RS 0 } .SH SEE ALSO basic_ostream(3C++), basic_iostream(3C++), basic_filebuf(3C++), cout(3C++), cin(3C++), clog(3C++), wcin(3C++), wcout(3C++), wcerr(3C++), wclog(3C++), iomanip(3C++), ios_base(3C++), basic_ios(3C++) Working Paper for Draft Proposed International Standard for Information Systems--Programming Language C++, Section 27.3.1 .SH STANDARDS CONFORMANCE ANSI X3J16/ISO WG21 Joint C++ Committee