different between cout and cerr

May 28, 2012 at 4:06pm
can i know what exactly the difference between cerr and cout? when should used cerr and when should used cout?
May 28, 2012 at 4:12pm
std::cout writes to a different stream than std::cerr, and std::cerr doesn't have a buffer (which std::cout does). Generally a terminal will display both streams, though.

As a rule of thumb, I use std::cout for processed data and data that I might want to forward to another application for more processing, and std::cerr for errors, notices, and data that shouldn't really be included in the other stream (in my opinion). That's me, though. :)

-Albatross
Last edited on May 28, 2012 at 4:14pm
May 28, 2012 at 4:28pm
std::cout - Regular output (console output)
std::cerr - Error output (console error)
std::clog - Nobody cares (console log)
May 28, 2012 at 4:36pm
I don't think cout is guaranteed to be buffered, and cerr may be line buffered iirc.
May 28, 2012 at 5:33pm
just get confuse about these kind of output console.... thanks for clearing my mind!
Topic archived. No new replies allowed.