views:

839

answers:

5

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.

+15  A: 

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

JRL
It would be nice to have a reference from a standards document or one of Stroustrup's works for this - I can't find one, and random web pages don't count, I'm afraid.
anon
I always thought it referred to C as in C++ :) (havent thought about it much...)
Viktor Sehr
+1 Good point, it must be console.
fastcodejava
The link is wrong, see @Fred's answer
Motti
+1 The wcin, wcout, etc makes for good supporting evidence.
ongle
+34  A: 

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

FredOverflow
@FredOverflow Excellent - this is the correct answer.
anon
Good find, straight from the horse's mouth.
Motti
Bah, what does Stroustrup know about C++ ;) (+1)
ongle
If it is the right answer, it is not a very useful one! All iostream objects are character streams. cout, and cin are simply such objects instattiated on the stdout and stdin streams (normally the 'console'), so 'console' would seem more likley and more useful as an identifier. If they didn't already exists stdout and stdin would be obvious names for these. Of course few of the symbols in the standard library are exemplars of good naming!
Clifford
It's the good answer.
Rexxar
@clifford has a good point. Unfortunately, there's wcout (why don't C/C++ programmers use that?) which surely stands for "wide console". Why would anybody use a 80 column console window on modern LCD screens?
Hans Passant
A: 

I'd hazard a guess at Console, ConsoleIn, ConsoleOut, ConsoleError, ConsoleLog for example.

Jamie Keeling
+1  A: 

'C' means console

Arcs
+1  A: 

Edit: FredOverflow has found the right answer with a link toward Stroustrup web site.

A c++ standard draft (n1905.pdf on www.open-std.org, I don't have the exact link) seems to indicate that it comes from "C" : "C standard output" => cout

27.3 Standard iostream objects [lib.iostream.objects]

1- The header <iostream> declares objects that associate objects with the standard C streams provided for by the functions declared in <cstdio> (27.8.2).

[...]

27.3.1 Narrow stream objects [lib.narrow.stream.objects]

istream cin

1- The object cin controls input from a stream buffer associated with the object stdin, declared in <cstdio>.

[...]

Rexxar
The reason you accepted is the correct one.
anon