What does the "c" mean in the cout
, cin
, cerr
and clog
names?
I would say char
but I haven't found anything to confirm it.
The "c" in cout refers to "character" and "out" means "output". Hence cout means "character output". The cout object is used along with the insertion operator << in order to display a stream of characters.
The "c" in cin refers to "character" and "in" means "input". Hence cin means "character input". The cin object is used along with the extraction operator >> in order to receive a stream of characters.
In C++ input and output are performed in the form of a sequence of bytes or more commonly known as streams. cerr and clog both are associated with the standard C error output stream stderr but the cerr is the unbuffered standard error stream whereas the clog is the buffered standard error stream.
The "c" in cerr refers to "character" and "err" means "error". Hence cerr means "character error". The cerr object is used along with the insertion operator << in order to display error messages.
The "c" stands for "character" because iostreams map values to and from byte (char) representations. [Bjarne Stroustrup's C++ Style and Technique FAQ]
I originally guessed console, and this link confirmed it. But after seeing the quote from Stroustrup, it seems that's a misconception, and that the c stands for character.
One thing in favor of that theory that can serve as an indicator is the fact that for each stream object (cin
, cout
, cerr
, etc.) there is an equivalent, wide-stream one (wcin
, wcout
, wcerr
, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With