- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What is C++ Standard Output Stream (cout)?
std::cout is an object of class ostream that represents the standard output stream oriented to narrow characters (of type char). It corresponds to the C stream stdout. The standard output stream is the default destination of characters determined by the environment. This destination may be shared with more standard objects (such as cerr or clog).
As an object of class ostream, characters can be written to it either as formatted data using the insertion operator (operator<<) or as unformatted data, using member functions such as write. The object is declared in the header <iostream> with external linkage and static duration: it lasts the entire duration of the program.
You can use this object to write to the screen. For example, if you want to write "Hello" to the screen, you'd write −
Example
#include<iostream> int main() { std::cout << "Hello"; return 0; }
Then save this program to hello.cpp file. Finally navigate to the saved location of this file in the terminal/cmd and compile it using −
$ g++ hello.cpp
Run it using −
$ ./a.out
Output
This will give the output −
Hello
- Related Articles
- Getting the Standard Output and Standard Error Output Stream through Console in C#
- What is C++ Standard Error Stream (cerr)?
- How to get the Standard Input and Output Stream through Console in C#?
- Standard Input Stream (cin) in C++
- What is the difference between printf() and cout in C++?
- What is the difference between cerr and cout streams in c++?
- What is the difference between cin and cout streams in c++?
- How to flush output stream after writing bytes
- What are cin, cout and cerr streams in C++?
- cout
- What is STREAM?
- What is DIX Standard?
- What is British standard system and international standard system?
- What is RS 232C Standard?
- What are Standard Libraries in C++?
