What is the meaning of the word "Cout" in C/C++?

Asked

Viewed 37,459 times

14

Well, it is very common in programming languages to have responsible keywords for printing data output.

Some are classic like echo, print, printf and write, etc..

But in the C/C++ we have the cout. For me, this word makes no sense to be related to printing data (I mean in a translation, for example). I couldn’t even find a translation for that word.

For example:

int main()
{
   cout << "Imprimindo o famoso HELLO WORLD!!!\n";

   return 0;
} 

What is the meaning of the word cout after all?

  • fopen() it’s also not so obvious so hehe.

  • @rray f => file.

  • In C the identifier cout is not reserved. You can use it for whatever you want, for example: int cout = 42; or struct cout { double cin; }; ...

1 answer

21


The cout is not a language keyword, is a standard library object and can only be used through the namespace std and inclusion of header iostream.

The meaning would be output console. Just as cin would be input console. Both are streams input and output data through the console.

There are those who consider that the "c" would be Character. At least is what the creator of language says. It’s weird but it makes some sense because underneath everything that’s sent to the stream ends up being converted to characters going to the console (contrary to what other types think are not printed, only one string, so every kind needs to be able to be converted to string somehow, even without creating a new object).

  • 2

    Ah, it’s explained. And I thought it was because I couldn’t use it alone out for perhaps already being reserved. :)

  • +1 simple and direct :D

  • 1

    Just a little correction, std::cout is not a function but a global object.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.