What is the difference between cout<< and cerr<< | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is the difference between cout<< and cerr<<

28th Mar 2017, 8:04 AM
Kaka
Kaka - avatar
4 Answers
+ 8
Both of the above statements will be en-route the output to the the standard output device i.e., monitor, by default, but semantically both are different in essence that cout<< represent standard output stream and cerr<< represent standard error stream
28th Mar 2017, 8:53 AM
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender)
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender) - avatar
+ 6
With cerr<< the output is immediately sent to the standard error stream while cout<< the output first goes to the buffer
28th Mar 2017, 8:08 AM
Kaka
Kaka - avatar
+ 4
@Devender What about clog<<
28th Mar 2017, 9:22 AM
Kaka
Kaka - avatar
+ 3
clog<< is rarely used. In fact is mere a clone of cerr <<
28th Mar 2017, 12:03 PM
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender)
เคฆเฅ‡เคตเฅ‡เค‚เคฆเฅเคฐ เคฎเคนเคพเคœเคจ (Devender) - avatar