TITLE: clarification on "what is clog" PROBLEM: furufuru@ccsr.u-tokyo.ac.jp (Furue Ryo) I'm looking for a document for clog. I know it's an object of the class i/ostream like cin, cout, and cerr, but I don't know its purpose and usage. Could someone refer me to some document (preferably one from some ftp site)? Or, if it's easy to explain, I'd appreciate your posting some explanation. RESPONSE: rmartin@rcmcon.com (Robert Martin), 23 Oct 95 clog and cerr both output to 'standard error'. cerr is buffered, clog is not. Buffering is an efficiency issue. It is much more efficient to use the buffered form (cerr). However, buffering means that the output won't be written right away. Thus, on a crash or other abnormal exit, your error messages might be stuck in the buffer instead of being written out. clog allows the errors to be written out right away. RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 23 Oct 95 Almost right. 'cerr' is unit-buffered, 'clog' is fully buffered. Unit- buffered means that each individual output operation is sent to the output stream at its conclusion. Unbuffered means that each individual character is immediately sent to the output stream. Unit-buffering is a good efficiency compromise. Example: clog << "The answer is " << x; or cerr << "The answer is " << x; or unbuffered_stream << "The answer is " << x; Suppose that 'x' should display as '1234', and that for some reason the program aborts after inserting the '12' but before inserting the '34'. clog would display nothing cerr would display: The answer is unbuffered_stream would display: The answer is 12 RESPONSE: clarke@ses.com (Allan Clarke), 25 Oct 95 Above are the sequences of discussion between you and Robert Martin recently concerning clog. I understand Robert's explaination well enough. I understand your explaination of unit-buffering. What I don't understand is that clog is fully buffered. How does this help in getting output written right away (ie, as an aid in debugging)? In particular, it seems that your example shows that for debugging output, it is better to use cerr than clog (ie, you would at least see "The answer is"). RESPONSE: clamage@Eng.Sun.COM (Steve Clamage), 25 Oct 95 I should have been more explicit that Robert got it backwards. cerr is (almost) unbuffered, clog is fully buffered. If you need to see output right away, you should use cerr. If you are accumulating data to the standard error file and don't want the overhead of frequent flushes, use clog.