Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the "c" mean in cout, cin, cerr and clog?

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.

like image 434
Rexxar Avatar asked Feb 14 '10 18:02

Rexxar


People also ask

What does C stand for in cout?

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.

What does the C in CIN stand for?

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.

What is CERR and clog in C++?

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.

What is CERR in C?

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.


2 Answers

The "c" stands for "character" because iostreams map values to and from byte (char) representations. [Bjarne Stroustrup's C++ Style and Technique FAQ]

like image 123
fredoverflow Avatar answered Sep 30 '22 21:09

fredoverflow


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.).

like image 29
JRL Avatar answered Sep 30 '22 21:09

JRL